@intlayer/design-system 3.0.3 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.vite/manifest.json +521 -395
- package/dist/Form-2XHQV7F_.cjs +295 -0
- package/dist/Form-2XHQV7F_.cjs.map +1 -0
- package/dist/Form-BO0i3nT9.js +300 -0
- package/dist/Form-BO0i3nT9.js.map +1 -0
- package/dist/Form-BaHDK0RZ.cjs +298 -0
- package/dist/Form-BaHDK0RZ.cjs.map +1 -0
- package/dist/Form-BfZMqK2D.js +300 -0
- package/dist/Form-BfZMqK2D.js.map +1 -0
- package/dist/Form-C13KWSZs.cjs +299 -0
- package/dist/Form-C13KWSZs.cjs.map +1 -0
- package/dist/Form-C8K2f8ph.js +300 -0
- package/dist/Form-C8K2f8ph.js.map +1 -0
- package/dist/Form-CKvCgz8c.cjs +299 -0
- package/dist/Form-CKvCgz8c.cjs.map +1 -0
- package/dist/Form-Cbk5Lhpd.js +299 -0
- package/dist/Form-Cbk5Lhpd.js.map +1 -0
- package/dist/Form-CiAgFAPb.cjs +300 -0
- package/dist/Form-CiAgFAPb.cjs.map +1 -0
- package/dist/Form-CnBKDneQ.js +296 -0
- package/dist/Form-CnBKDneQ.js.map +1 -0
- package/dist/Form-DERuauvB.cjs +300 -0
- package/dist/Form-DERuauvB.cjs.map +1 -0
- package/dist/Form-DhlDf3ML.cjs +299 -0
- package/dist/Form-DhlDf3ML.cjs.map +1 -0
- package/dist/Form-DkAZ0Jdf.cjs +299 -0
- package/dist/Form-DkAZ0Jdf.cjs.map +1 -0
- package/dist/Form-DqnNP4DA.js +300 -0
- package/dist/Form-DqnNP4DA.js.map +1 -0
- package/dist/Form-DyFBmVya.js +301 -0
- package/dist/Form-DyFBmVya.js.map +1 -0
- package/dist/Form-FW4Odjfm.js +301 -0
- package/dist/Form-FW4Odjfm.js.map +1 -0
- package/dist/components/Accordion/Accordion.d.ts +0 -1
- package/dist/components/Auth/AuthModal/index.d.ts +0 -1
- package/dist/components/Auth/AuthProvider/index.cjs +5 -21
- package/dist/components/Auth/AuthProvider/index.cjs.map +1 -1
- package/dist/components/Auth/AuthProvider/index.d.ts +4 -3
- package/dist/components/Auth/AuthProvider/index.d.ts.map +1 -1
- package/dist/components/Auth/AuthProvider/index.mjs +6 -22
- package/dist/components/Auth/AuthProvider/index.mjs.map +1 -1
- package/dist/components/Auth/AuthProvider/useSession.cjs +7 -3
- package/dist/components/Auth/AuthProvider/useSession.cjs.map +1 -1
- package/dist/components/Auth/AuthProvider/useSession.d.ts +0 -1
- package/dist/components/Auth/AuthProvider/useSession.d.ts.map +1 -1
- package/dist/components/Auth/AuthProvider/useSession.mjs +7 -3
- package/dist/components/Auth/AuthProvider/useSession.mjs.map +1 -1
- package/dist/components/Auth/AuthenticationBarrier/AuthenticationBarrierClient.d.ts +0 -1
- package/dist/components/Auth/AuthenticationBarrier/AuthenticationBarrierServer.d.ts +0 -1
- package/dist/components/Auth/AuthenticationBarrier/accessValidation.d.ts +0 -1
- package/dist/components/Auth/AuthenticationBarrier/index.d.ts +0 -1
- package/dist/components/Auth/ChangePasswordForm/ChangePasswordForm.cjs +1 -1
- package/dist/components/Auth/ChangePasswordForm/ChangePasswordForm.d.ts +0 -1
- package/dist/components/Auth/ChangePasswordForm/ChangePasswordForm.mjs +1 -1
- package/dist/components/Auth/ChangePasswordForm/ChangePasswordSchema.cjs.map +1 -1
- package/dist/components/Auth/ChangePasswordForm/ChangePasswordSchema.d.ts +0 -1
- package/dist/components/Auth/ChangePasswordForm/ChangePasswordSchema.mjs.map +1 -1
- package/dist/components/Auth/ChangePasswordForm/index.content.cjs.map +1 -1
- package/dist/components/Auth/ChangePasswordForm/index.content.d.ts +10 -10
- package/dist/components/Auth/ChangePasswordForm/index.content.mjs.map +1 -1
- package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.d.ts +0 -1
- package/dist/components/Auth/ExternalsLoginButtons/assets/GithubLogo.d.ts +0 -1
- package/dist/components/Auth/ExternalsLoginButtons/assets/GoogleLogo.d.ts +0 -1
- package/dist/components/Auth/ExternalsLoginButtons/externalsLoginButtons.content.cjs.map +1 -1
- package/dist/components/Auth/ExternalsLoginButtons/externalsLoginButtons.content.d.ts +5 -5
- package/dist/components/Auth/ExternalsLoginButtons/externalsLoginButtons.content.mjs.map +1 -1
- package/dist/components/Auth/ResetPasswordForm/ResetPasswordForm.cjs +1 -1
- package/dist/components/Auth/ResetPasswordForm/ResetPasswordForm.d.ts +0 -1
- package/dist/components/Auth/ResetPasswordForm/ResetPasswordForm.mjs +1 -1
- package/dist/components/Auth/ResetPasswordForm/ResetPasswordSchema.cjs.map +1 -1
- package/dist/components/Auth/ResetPasswordForm/ResetPasswordSchema.d.ts +0 -1
- package/dist/components/Auth/ResetPasswordForm/ResetPasswordSchema.mjs.map +1 -1
- package/dist/components/Auth/ResetPasswordForm/index.content.cjs.map +1 -1
- package/dist/components/Auth/ResetPasswordForm/index.content.d.ts +7 -7
- package/dist/components/Auth/ResetPasswordForm/index.content.mjs.map +1 -1
- package/dist/components/Auth/SignInForm/SignInForm.cjs +1 -1
- package/dist/components/Auth/SignInForm/SignInForm.d.ts +0 -1
- package/dist/components/Auth/SignInForm/SignInForm.mjs +1 -1
- package/dist/components/Auth/SignInForm/SignInSchema.cjs.map +1 -1
- package/dist/components/Auth/SignInForm/SignInSchema.d.ts +0 -1
- package/dist/components/Auth/SignInForm/SignInSchema.mjs.map +1 -1
- package/dist/components/Auth/SignInForm/index.content.cjs.map +1 -1
- package/dist/components/Auth/SignInForm/index.content.d.ts +13 -13
- package/dist/components/Auth/SignInForm/index.content.mjs.map +1 -1
- package/dist/components/Auth/SignUpForm/SignUpForm.cjs +1 -1
- package/dist/components/Auth/SignUpForm/SignUpForm.d.ts +0 -1
- package/dist/components/Auth/SignUpForm/SignUpForm.mjs +1 -1
- package/dist/components/Auth/SignUpForm/SignUpSchema.cjs.map +1 -1
- package/dist/components/Auth/SignUpForm/SignUpSchema.d.ts +0 -1
- package/dist/components/Auth/SignUpForm/SignUpSchema.mjs.map +1 -1
- package/dist/components/Auth/SignUpForm/index.content.cjs.map +1 -1
- package/dist/components/Auth/SignUpForm/index.content.d.ts +11 -11
- package/dist/components/Auth/SignUpForm/index.content.mjs.map +1 -1
- package/dist/components/Avatar/index.d.ts +0 -1
- package/dist/components/Badge/index.d.ts +1 -2
- package/dist/components/Breadcrumb/index.d.ts +0 -1
- package/dist/components/Button/Button.cjs +1 -0
- package/dist/components/Button/Button.cjs.map +1 -1
- package/dist/components/Button/Button.d.ts +2 -3
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Button/Button.mjs +1 -0
- package/dist/components/Button/Button.mjs.map +1 -1
- package/dist/components/Command/index.d.ts +9 -10
- package/dist/components/Command/index.d.ts.map +1 -1
- package/dist/components/Container/index.cjs.map +1 -1
- package/dist/components/Container/index.d.ts +16 -3
- package/dist/components/Container/index.d.ts.map +1 -1
- package/dist/components/Container/index.mjs.map +1 -1
- package/dist/components/ContentEditor/ContentEditor.d.ts +0 -1
- package/dist/components/ContentEditor/ContentEditorTextArea.d.ts +0 -1
- package/dist/components/ContentSelector/ContentSelector.d.ts +0 -1
- package/dist/components/CopyToClipboard/index.d.ts +0 -1
- package/dist/components/DictionaryEditor/DictionaryEditor.cjs +30 -24
- package/dist/components/DictionaryEditor/DictionaryEditor.cjs.map +1 -1
- package/dist/components/DictionaryEditor/DictionaryEditor.d.ts +0 -7
- package/dist/components/DictionaryEditor/DictionaryEditor.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/DictionaryEditor.mjs +30 -24
- package/dist/components/DictionaryEditor/DictionaryEditor.mjs.map +1 -1
- package/dist/components/DictionaryEditor/ItemLayout.cjs +1 -0
- package/dist/components/DictionaryEditor/ItemLayout.cjs.map +1 -1
- package/dist/components/DictionaryEditor/ItemLayout.d.ts +0 -1
- package/dist/components/DictionaryEditor/ItemLayout.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/ItemLayout.mjs +1 -0
- package/dist/components/DictionaryEditor/ItemLayout.mjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.d.ts +0 -1
- package/dist/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.d.ts +0 -1
- package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.d.ts +0 -1
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.cjs +7 -5
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.cjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.d.ts +0 -1
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.mjs +7 -5
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.mjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/TranslationWrapper.d.ts +0 -1
- package/dist/components/DictionaryEditor/NodeWrapper/index.d.ts +0 -1
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs +111 -19
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs.map +1 -1
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.d.ts +1 -5
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs +112 -20
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs.map +1 -1
- package/dist/components/DictionaryEditor/useEditedContentStore.cjs +18 -20
- package/dist/components/DictionaryEditor/useEditedContentStore.cjs.map +1 -1
- package/dist/components/DictionaryEditor/useEditedContentStore.d.ts +0 -1
- package/dist/components/DictionaryEditor/useEditedContentStore.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/useEditedContentStore.mjs +19 -21
- package/dist/components/DictionaryEditor/useEditedContentStore.mjs.map +1 -1
- package/dist/components/DictionaryEditor/useEditionPanelStore.d.ts +0 -1
- package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.cjs +67 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.cjs.map +1 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.d.ts +27 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.d.ts.map +1 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.mjs +67 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.mjs.map +1 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtonsSchema.cjs +8 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtonsSchema.cjs.map +1 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtonsSchema.d.ts +4 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtonsSchema.d.ts.map +1 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtonsSchema.mjs +8 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtonsSchema.mjs.map +1 -0
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.cjs +8 -2
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.mjs +8 -2
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryFormSchema.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryFormSchema.d.ts +2 -3
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryFormSchema.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryFormSchema.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsSchema.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsSchema.d.ts +2 -3
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsSchema.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsSchema.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.cjs +2 -2
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.mjs +2 -2
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs +37 -13
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +37 -13
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.cjs +21 -6
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.mjs +21 -6
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.cjs +29 -14
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.mjs +29 -14
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EnumKeyInput.cjs +1 -0
- package/dist/components/DictionaryFieldEditor/EnumKeyInput.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EnumKeyInput.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/EnumKeyInput.mjs +1 -0
- package/dist/components/DictionaryFieldEditor/EnumKeyInput.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/KeyPathBreadcrumb.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs +18 -2
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +18 -2
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.cjs +18 -2
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.mjs +18 -2
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +14 -15
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +14 -15
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveFormSchema.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.cjs +12 -12
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.d.ts +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.mjs +12 -12
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.d.ts +0 -1
- package/dist/components/DropDown/index.d.ts +0 -1
- package/dist/components/DropDown/types.d.ts +0 -1
- package/dist/components/EditableField/EditableFieldInput.cjs +12 -5
- package/dist/components/EditableField/EditableFieldInput.cjs.map +1 -1
- package/dist/components/EditableField/EditableFieldInput.d.ts +2 -4
- package/dist/components/EditableField/EditableFieldInput.d.ts.map +1 -1
- package/dist/components/EditableField/EditableFieldInput.mjs +13 -6
- package/dist/components/EditableField/EditableFieldInput.mjs.map +1 -1
- package/dist/components/EditableField/EditableFieldLayout.d.ts +0 -1
- package/dist/components/EditableField/EditableFieldTextArea.cjs +17 -4
- package/dist/components/EditableField/EditableFieldTextArea.cjs.map +1 -1
- package/dist/components/EditableField/EditableFieldTextArea.d.ts +6 -3
- package/dist/components/EditableField/EditableFieldTextArea.d.ts.map +1 -1
- package/dist/components/EditableField/EditableFieldTextArea.mjs +18 -5
- package/dist/components/EditableField/EditableFieldTextArea.mjs.map +1 -1
- package/dist/components/Flags/Flag.d.ts +0 -1
- package/dist/components/Footer/index.d.ts +0 -1
- package/dist/components/Form/Form.cjs +1 -1
- package/dist/components/Form/Form.d.ts +2 -1
- package/dist/components/Form/Form.d.ts.map +1 -1
- package/dist/components/Form/Form.mjs +1 -1
- package/dist/components/Form/FormBase.d.ts +0 -1
- package/dist/components/Form/FormBase.d.ts.map +1 -1
- package/dist/components/Form/FormDescription.d.ts +0 -1
- package/dist/components/Form/FormField.d.ts +0 -1
- package/dist/components/Form/FormItem.d.ts +0 -1
- package/dist/components/Form/FormMessage.d.ts +0 -1
- package/dist/components/Form/elements/CheckboxElement.cjs +10 -0
- package/dist/components/Form/elements/CheckboxElement.cjs.map +1 -0
- package/dist/components/Form/elements/CheckboxElement.d.ts +10 -0
- package/dist/components/Form/elements/CheckboxElement.d.ts.map +1 -0
- package/dist/components/Form/elements/CheckboxElement.mjs +10 -0
- package/dist/components/Form/elements/CheckboxElement.mjs.map +1 -0
- package/dist/components/Form/elements/EditableFieldInputElement.cjs +1 -1
- package/dist/components/Form/elements/EditableFieldInputElement.d.ts +0 -1
- package/dist/components/Form/elements/EditableFieldInputElement.mjs +1 -1
- package/dist/components/Form/elements/EditableFieldTextAreaElement.cjs +1 -1
- package/dist/components/Form/elements/EditableFieldTextAreaElement.d.ts +0 -1
- package/dist/components/Form/elements/EditableFieldTextAreaElement.mjs +1 -1
- package/dist/components/Form/elements/FormElement.cjs +1 -1
- package/dist/components/Form/elements/FormElement.d.ts +0 -1
- package/dist/components/Form/elements/FormElement.mjs +1 -1
- package/dist/components/Form/elements/FormElementWrapper.d.ts +0 -1
- package/dist/components/Form/elements/InputElement.cjs +2 -1
- package/dist/components/Form/elements/InputElement.cjs.map +1 -1
- package/dist/components/Form/elements/InputElement.d.ts +2 -3
- package/dist/components/Form/elements/InputElement.d.ts.map +1 -1
- package/dist/components/Form/elements/InputElement.mjs +2 -1
- package/dist/components/Form/elements/InputElement.mjs.map +1 -1
- package/dist/components/Form/elements/InputPasswordElement.cjs +2 -1
- package/dist/components/Form/elements/InputPasswordElement.cjs.map +1 -1
- package/dist/components/Form/elements/InputPasswordElement.d.ts +2 -3
- package/dist/components/Form/elements/InputPasswordElement.d.ts.map +1 -1
- package/dist/components/Form/elements/InputPasswordElement.mjs +2 -1
- package/dist/components/Form/elements/InputPasswordElement.mjs.map +1 -1
- package/dist/components/Form/elements/MultiselectElement.cjs +1 -1
- package/dist/components/Form/elements/MultiselectElement.d.ts +0 -1
- package/dist/components/Form/elements/MultiselectElement.mjs +1 -1
- package/dist/components/Form/elements/SelectElement.cjs +1 -1
- package/dist/components/Form/elements/SelectElement.d.ts +0 -1
- package/dist/components/Form/elements/SelectElement.mjs +1 -1
- package/dist/components/Form/elements/SwitchSelectorElement.cjs +1 -1
- package/dist/components/Form/elements/SwitchSelectorElement.d.ts +0 -1
- package/dist/components/Form/elements/SwitchSelectorElement.mjs +1 -1
- package/dist/components/Form/elements/TextAreaElement.cjs +1 -1
- package/dist/components/Form/elements/TextAreaElement.d.ts +0 -1
- package/dist/components/Form/elements/TextAreaElement.mjs +1 -1
- package/dist/components/Form/elements/index.cjs +1 -1
- package/dist/components/Form/elements/index.mjs +1 -1
- package/dist/components/Form/index.cjs +1 -1
- package/dist/components/Form/index.mjs +1 -1
- package/dist/components/Form/layout/FormItemLayout.cjs +1 -1
- package/dist/components/Form/layout/FormItemLayout.d.ts +1 -2
- package/dist/components/Form/layout/FormItemLayout.d.ts.map +1 -1
- package/dist/components/Form/layout/FormItemLayout.mjs +1 -1
- package/dist/components/Form/layout/FormLabelLayout.d.ts +0 -1
- package/dist/components/Form/layout/RequiredStar.d.ts +0 -1
- package/dist/components/Form/layout/index.cjs +1 -1
- package/dist/components/Form/layout/index.mjs +1 -1
- package/dist/components/Headers/index.d.ts +0 -1
- package/dist/components/IDE/CodeRender.cjs.map +1 -1
- package/dist/components/IDE/CodeRender.d.ts +0 -1
- package/dist/components/IDE/CodeRender.mjs.map +1 -1
- package/dist/components/IDE/FileList.d.ts +0 -1
- package/dist/components/IDE/FileTree.d.ts +0 -1
- package/dist/components/IDE/IDE.d.ts +0 -1
- package/dist/components/IDE/MarkDownRender.d.ts +0 -1
- package/dist/components/InformationTag/index.d.ts +0 -1
- package/dist/components/Input/Checkbox.cjs +80 -0
- package/dist/components/Input/Checkbox.cjs.map +1 -0
- package/dist/components/Input/Checkbox.d.ts +14 -0
- package/dist/components/Input/Checkbox.d.ts.map +1 -0
- package/dist/components/Input/Checkbox.mjs +80 -0
- package/dist/components/Input/Checkbox.mjs.map +1 -0
- package/dist/components/Input/Input.d.ts +0 -1
- package/dist/components/Input/InputPassword.d.ts +0 -1
- package/dist/components/Input/index.cjs +3 -0
- package/dist/components/Input/index.cjs.map +1 -1
- package/dist/components/Input/index.d.ts +1 -0
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Input/index.mjs +3 -0
- package/dist/components/Input/index.mjs.map +1 -1
- package/dist/components/Label/index.d.ts +0 -1
- package/dist/components/Link/Link.cjs +7 -2
- package/dist/components/Link/Link.cjs.map +1 -1
- package/dist/components/Link/Link.d.ts +3 -3
- package/dist/components/Link/Link.d.ts.map +1 -1
- package/dist/components/Link/Link.mjs +7 -2
- package/dist/components/Link/Link.mjs.map +1 -1
- package/dist/components/Loader/index.d.ts +0 -1
- package/dist/components/Loader/spinner.d.ts +0 -1
- package/dist/components/LocaleSwitcherDropDown/LocaleSwitcher.d.ts +0 -1
- package/dist/components/Logo/LogoCircle.d.ts +0 -1
- package/dist/components/Logo/LogoNoFrame.d.ts +0 -1
- package/dist/components/Logo/LogoSquare.d.ts +0 -1
- package/dist/components/Logo/LogoSquircle.d.ts +0 -1
- package/dist/components/Logo/LogoTextOnly.d.ts +0 -1
- package/dist/components/Logo/LogoWithTextBelowCircle.d.ts +0 -1
- package/dist/components/Logo/LogoWithTextBelowNoFrame.d.ts +0 -1
- package/dist/components/Logo/LogoWithTextBelowSquircle.d.ts +0 -1
- package/dist/components/Logo/LogoWithTextCircle.d.ts +0 -1
- package/dist/components/Logo/LogoWithTextNoFrame.d.ts +0 -1
- package/dist/components/Logo/LogoWithTextSquircle.d.ts +0 -1
- package/dist/components/Logo/index.d.ts +0 -1
- package/dist/components/MarkDownRender/index.d.ts +0 -1
- package/dist/components/MaxHeightSmoother/index.d.ts +0 -1
- package/dist/components/MaxWidthSmoother/index.d.ts +0 -1
- package/dist/components/Modal/Modal.cjs +19 -15
- package/dist/components/Modal/Modal.cjs.map +1 -1
- package/dist/components/Modal/Modal.d.ts +3 -3
- package/dist/components/Modal/Modal.d.ts.map +1 -1
- package/dist/components/Modal/Modal.mjs +19 -15
- package/dist/components/Modal/Modal.mjs.map +1 -1
- package/dist/components/Navbar/Burger.d.ts +0 -1
- package/dist/components/Navbar/DesktopNavbar.cjs +10 -26
- package/dist/components/Navbar/DesktopNavbar.cjs.map +1 -1
- package/dist/components/Navbar/DesktopNavbar.d.ts +6 -6
- package/dist/components/Navbar/DesktopNavbar.d.ts.map +1 -1
- package/dist/components/Navbar/DesktopNavbar.mjs +10 -26
- package/dist/components/Navbar/DesktopNavbar.mjs.map +1 -1
- package/dist/components/Navbar/MobileNavbar.cjs +3 -57
- package/dist/components/Navbar/MobileNavbar.cjs.map +1 -1
- package/dist/components/Navbar/MobileNavbar.d.ts +6 -7
- package/dist/components/Navbar/MobileNavbar.d.ts.map +1 -1
- package/dist/components/Navbar/MobileNavbar.mjs +3 -57
- package/dist/components/Navbar/MobileNavbar.mjs.map +1 -1
- package/dist/components/Navbar/index.cjs +4 -2
- package/dist/components/Navbar/index.cjs.map +1 -1
- package/dist/components/Navbar/index.d.ts +9 -15
- package/dist/components/Navbar/index.d.ts.map +1 -1
- package/dist/components/Navbar/index.mjs +4 -2
- package/dist/components/Navbar/index.mjs.map +1 -1
- package/dist/components/Pattern/DotPattern.d.ts +0 -1
- package/dist/components/Pattern/GridPattern.d.ts +0 -1
- package/dist/components/Pattern/SpotLight.d.ts +0 -1
- package/dist/components/Popover/index.d.ts +0 -1
- package/dist/components/PressableSpan/PressableSpan.d.ts +0 -1
- package/dist/components/ProfileDropDown/index.d.ts +0 -1
- package/dist/components/RightDrawer/RightDrawer.d.ts +0 -1
- package/dist/components/Select/Multiselect.d.ts +2 -3
- package/dist/components/Select/Multiselect.d.ts.map +1 -1
- package/dist/components/SwitchSelector/index.d.ts +1 -2
- package/dist/components/TabSelector/TabSelector.cjs +2 -0
- package/dist/components/TabSelector/TabSelector.cjs.map +1 -1
- package/dist/components/TabSelector/TabSelector.d.ts +2 -3
- package/dist/components/TabSelector/TabSelector.d.ts.map +1 -1
- package/dist/components/TabSelector/TabSelector.mjs +2 -0
- package/dist/components/TabSelector/TabSelector.mjs.map +1 -1
- package/dist/components/TextArea/AutoSizeTextArea.d.ts +0 -1
- package/dist/components/TextArea/TextArea.cjs +1 -0
- package/dist/components/TextArea/TextArea.cjs.map +1 -1
- package/dist/components/TextArea/TextArea.d.ts +0 -1
- package/dist/components/TextArea/TextArea.mjs +1 -0
- package/dist/components/TextArea/TextArea.mjs.map +1 -1
- package/dist/components/ThemeSwitcherDropDown/DesktopThemeSwitcher.d.ts +0 -1
- package/dist/components/ThemeSwitcherDropDown/MobileThemeSwitcher.d.ts +0 -1
- package/dist/components/Toaster/Toast.d.ts +1 -1
- package/dist/components/Toaster/useToast.d.ts +0 -1
- package/dist/components/WithResizer/index.d.ts +0 -1
- package/dist/components/index.cjs +4 -3
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.mjs +4 -3
- package/dist/hooks/intlayerAPIHooks.cjs +16 -3
- package/dist/hooks/intlayerAPIHooks.cjs.map +1 -1
- package/dist/hooks/intlayerAPIHooks.d.ts +0 -1
- package/dist/hooks/intlayerAPIHooks.d.ts.map +1 -1
- package/dist/hooks/intlayerAPIHooks.mjs +16 -3
- package/dist/hooks/intlayerAPIHooks.mjs.map +1 -1
- package/dist/hooks/useAsync/useAsync.cjs +1 -5
- package/dist/hooks/useAsync/useAsync.cjs.map +1 -1
- package/dist/hooks/useAsync/useAsync.d.ts.map +1 -1
- package/dist/hooks/useAsync/useAsync.mjs +1 -5
- package/dist/hooks/useAsync/useAsync.mjs.map +1 -1
- package/dist/hooks/useAsync/useAsyncWrapper.d.ts +0 -1
- package/dist/hooks/useGetAllDictionaries.d.ts +0 -1
- package/dist/hooks/useItemSelector.d.ts +0 -1
- package/dist/index-BUDsCMdX.cjs +204 -0
- package/dist/index-BUDsCMdX.cjs.map +1 -0
- package/dist/index-C09rI9kw.js +205 -0
- package/dist/index-C09rI9kw.js.map +1 -0
- package/dist/libs/intlayer-api/auth.d.ts +0 -1
- package/dist/libs/intlayer-api/dictionary.d.ts +0 -1
- package/dist/libs/intlayer-api/fetcher.cjs +1 -6
- package/dist/libs/intlayer-api/fetcher.cjs.map +1 -1
- package/dist/libs/intlayer-api/fetcher.d.ts.map +1 -1
- package/dist/libs/intlayer-api/fetcher.mjs +1 -6
- package/dist/libs/intlayer-api/fetcher.mjs.map +1 -1
- package/dist/libs/intlayer-api/index.d.ts +0 -1
- package/dist/libs/intlayer-api/organization.d.ts +0 -1
- package/dist/libs/intlayer-api/project.d.ts +0 -1
- package/dist/libs/intlayer-api/user.d.ts +0 -1
- package/dist/tailwind.css +1 -1
- package/dist/utils/cn.d.ts +0 -1
- package/dist/utils/dictionary.cjs +37 -1
- package/dist/utils/dictionary.cjs.map +1 -1
- package/dist/utils/dictionary.d.ts +1 -1
- package/dist/utils/dictionary.d.ts.map +1 -1
- package/dist/utils/dictionary.mjs +38 -2
- package/dist/utils/dictionary.mjs.map +1 -1
- package/dist/validDictionaryChangeButtons.content-BK9QaXPm.cjs +66 -0
- package/dist/validDictionaryChangeButtons.content-BK9QaXPm.cjs.map +1 -0
- package/dist/validDictionaryChangeButtons.content-CAAscqJI.cjs +66 -0
- package/dist/validDictionaryChangeButtons.content-CAAscqJI.cjs.map +1 -0
- package/dist/validDictionaryChangeButtons.content-D7AvoBdl.js +67 -0
- package/dist/validDictionaryChangeButtons.content-D7AvoBdl.js.map +1 -0
- package/dist/validDictionaryChangeButtons.content-DQwoUNCC.cjs +45 -0
- package/dist/validDictionaryChangeButtons.content-DQwoUNCC.cjs.map +1 -0
- package/dist/validDictionaryChangeButtons.content-DQxPoIe6.js +67 -0
- package/dist/validDictionaryChangeButtons.content-DQxPoIe6.js.map +1 -0
- package/dist/validDictionaryChangeButtons.content-JUcjGdBx.cjs +66 -0
- package/dist/validDictionaryChangeButtons.content-JUcjGdBx.cjs.map +1 -0
- package/dist/validDictionaryChangeButtons.content-ejY3-sbG.js +67 -0
- package/dist/validDictionaryChangeButtons.content-ejY3-sbG.js.map +1 -0
- package/dist/validDictionaryChangeButtons.content-iyT0lKy7.js +46 -0
- package/dist/validDictionaryChangeButtons.content-iyT0lKy7.js.map +1 -0
- package/dist/validDictionaryChangeButtons.content-u4qShrQh.cjs +66 -0
- package/dist/validDictionaryChangeButtons.content-u4qShrQh.cjs.map +1 -0
- package/dist/validDictionaryChangeButtons.content-y4up9NU8.js +67 -0
- package/dist/validDictionaryChangeButtons.content-y4up9NU8.js.map +1 -0
- package/dist/zod-BV4nCGJE.js.map +1 -1
- package/dist/zod-DSrtTSD_.cjs.map +1 -1
- package/package.json +81 -54
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAsync.cjs","sources":["../../../../../../node_modules/.pnpm/zustand@4.5.5_@types+react@18.3.11_react@18.3.1/node_modules/zustand/esm/react/shallow.mjs","../../../src/hooks/useAsync/useAsync.ts"],"sourcesContent":["import ReactExports from 'react';\n\nfunction shallow(objA, objB) {\n if (Object.is(objA, objB)) {\n return true;\n }\n if (typeof objA !== \"object\" || objA === null || typeof objB !== \"object\" || objB === null) {\n return false;\n }\n if (objA instanceof Map && objB instanceof Map) {\n if (objA.size !== objB.size) return false;\n for (const [key, value] of objA) {\n if (!Object.is(value, objB.get(key))) {\n return false;\n }\n }\n return true;\n }\n if (objA instanceof Set && objB instanceof Set) {\n if (objA.size !== objB.size) return false;\n for (const value of objA) {\n if (!objB.has(value)) {\n return false;\n }\n }\n return true;\n }\n const keysA = Object.keys(objA);\n if (keysA.length !== Object.keys(objB).length) {\n return false;\n }\n for (const keyA of keysA) {\n if (!Object.prototype.hasOwnProperty.call(objB, keyA) || !Object.is(objA[keyA], objB[keyA])) {\n return false;\n }\n }\n return true;\n}\n\nconst { useRef } = ReactExports;\nfunction useShallow(selector) {\n const prev = useRef();\n return (state) => {\n const next = selector(state);\n return shallow(prev.current, next) ? prev.current : prev.current = next;\n };\n}\n\nexport { useShallow };\n","'use client';\n\n// This is an ESLint directive to disable specific rules.\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { useCallback, useEffect, useRef } from 'react';\nimport { useShallow } from 'zustand/react/shallow';\nimport { useAsyncStateStore } from './useAsyncStateStore';\n\n// Pending promises cache to prevent parallel requests when multiple components use the hook\nconst pendingPromises = new Map();\n\n// Defines the base structure for the result of the custom hook.\ntype UseAsyncResultBase<T extends (...args: any[]) => Promise<any>> = {\n isFetched: boolean;\n isLoading: boolean;\n isInvalidated: boolean;\n isSuccess: boolean;\n isDisabled: boolean;\n error: string | null;\n data: Awaited<ReturnType<T>> | null;\n retryCount: number;\n revalidate: T;\n setData: (data: Awaited<ReturnType<T> | null>) => void;\n};\n\n// Options type for the hook, allowing customization of behavior.\nexport type UseAsyncOptions<T extends (...args: any[]) => Promise<any>> = {\n retryLimit?: number; // The number of times the hook should retry the function on failure before giving up\n retryTime?: number; // Time in milliseconds for retrying the data\n cache?: boolean; // Cache the result of the function using zustand\n store?: boolean; // Store the result of the function in session storage\n enable?: boolean; // Enable the hook\n autoFetch?: boolean; // Automatically fetch the data when the hook is mounted\n revalidation?: boolean; // Enable revalidation\n revalidateTime?: number; // Time in milliseconds for revalidating the data\n isInvalidated?: boolean; // Determine if the data is invalidated and should be refetched\n invalidateQueries?: string[]; // Invalidate other queries when the data is updated\n updateQueries?: string[]; // Update other queries when the data is updated\n onSuccess?: (data: Awaited<ReturnType<T>>) => void; // Callback function that is called when the asynchronous function resolves successfully\n onError?: (error: string) => void; // Callback function that is called when the asynchronous function rejects or encounters an error\n args?: Parameters<T>; // Arguments to pass to the asynchronous function\n};\n\n// Default values for the hook's options\nconst DEFAULT_CACHE_ENABLED = false;\nconst DEFAULT_STORE_ENABLED = false;\nconst DEFAULT_ENABLED = true;\nconst DEFAULT_AUTO_FETCH = false;\nconst DEFAULT_RETRY_LIMIT = 1;\nconst DEFAULT_REVALIDATION_ENABLED = false;\nconst DEFAULT_REVALIDATE_TIME = 5 * 60 * 1000; // 5 minutes\nconst DEFAULT_RETRY_TIME = 5 * 60 * 1000; // 5 minutes\n\n// The main hook type that includes the async function along with its additional properties.\nexport type UseAsyncResult<\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n> = UseAsyncResultBase<T> & Record<U, T>;\n\nconst getKeyWithArgs = (key: string, args: any[]) =>\n args.length > 0 ? `${key}/${JSON.stringify(args)}` : key;\n\n/**\n * A custom React hook that manages asynchronous operations, providing easy-to-use states and controls over fetching, caching, and retry mechanisms.\n * This hook abstracts away the complexity of handling loading, error, and success states for any asynchronous function.\n *\n * @template U - A string type that extends the keys of the async function, used as a key to store and retrieve state.\n * @template T - A function type that must return a Promise, representing the asynchronous operation to be managed.\n *\n * @param {U} key - A unique identifier for the async operation, used to handle state internally and avoid conflicts.\n * @param {T} asyncFunction - The asynchronous function that will be managed by this hook. This function should return a Promise.\n * @param {UseAsyncOptions<T>} [options] - Optional configuration options to customize the behavior of the hook.\n * @returns {UseAsyncResult<U, T>} The states and controls related to the managed async function. Includes states like isLoading, isSuccess, and provides control methods like revalidate and setData.\n *\n * @typedef {Object} UseAsyncOptions\n * @property {number} [retryTime=300000] - Time in milliseconds for retrying the data after an error occurs.\n * @property {number} [retryLimit=1] - The number of times the hook should retry the asynchronous function on failure before giving up.\n * @property {boolean} [revalidation=false] - Enable revalidation.\n * @property {number} [revalidateTime=300000] - Time in milliseconds after which the cached data is considered stale and the async function is re-invoked, if caching is enabled.\n * @property {boolean} [cache=false] - Whether to cache the result of the async function. When enabled, revalidation is controlled by `revalidateTime`.\n * @property {boolean} [store=false] - Store the result of the function in session storage.\n * @property {boolean} [autoFetch=false] - Whether the hook should automatically invoke the asynchronous function on mount.\n * @property {number} [revalidateTime=300000] - Time in milliseconds after which the cached data is considered stale and the async function is re-invoked, if caching is enabled.\n * @property {boolean} [isInvalidated=false] - Determine if the data is invalidated and should be refetched.\n * @property {string[]} [updateQueries=[]] - Update other queries when the data is updated.\n * @property {string[]} [invalidateQueries=[]] - Invalidate other queries when the data is updated.\n * @property {(data: Awaited<ReturnType<T>>) => void} [onSuccess] - Callback function that is called when the asynchronous function resolves successfully.\n * @property {(error: string) => void} [onError] - Callback function that is called when the asynchronous function rejects or encounters an error.\n * @property {Parameters<T>} [args=[]] - Arguments to pass to the asynchronous function.\n *\n *\n * @example\n * // Example of using useAsync to manage fetching user data from an API.\n * const fetchUserData = async (userId) => {\n * const response = await fetch(`/api/users/${userId}`);\n * if (!response.ok) throw new Error('Failed to fetch');\n * return await response.json();\n * };\n *\n * const UserDetails = ({ userId }) => {\n * const {\n * isLoading,\n * data,\n * error,\n * revalidate,\n * } = useAsync('userDetails', fetchUserData, {\n * cache: true,\n * revalidateTime: 60000, // 1 minute\n * autoFetch: true,\n * onSuccess: (data) => console.log('User data fetched successfully:', data),\n * onError: (error) => console.error('Error fetching user data:', error),\n * });\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error}</div>;\n * return (\n * <div>\n * <h1>{data.name}</h1>\n * <button onClick={() => revalidate()}>Refresh</button>\n * </div>\n * );\n * };\n */\nexport const useAsync = <\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n>(\n key: U,\n asyncFunction: T,\n options?: UseAsyncOptions<T>\n): UseAsyncResult<U, T> => {\n // Resolving optional parameters with default values\n const retryLimit = options?.retryLimit ?? DEFAULT_RETRY_LIMIT;\n const autoFetch = options?.autoFetch ?? DEFAULT_AUTO_FETCH;\n const retryTime = options?.retryTime ?? DEFAULT_RETRY_TIME;\n const cacheEnabled = options?.cache ?? DEFAULT_CACHE_ENABLED;\n const storeEnabled = options?.store ?? DEFAULT_STORE_ENABLED;\n const enabled = options?.enable ?? DEFAULT_ENABLED;\n const revalidationEnabled =\n options?.revalidation ?? DEFAULT_REVALIDATION_ENABLED;\n const revalidateTime = options?.revalidateTime ?? DEFAULT_REVALIDATE_TIME;\n const isInvalidatedProps = options?.isInvalidated ?? false;\n const updateQueries = options?.updateQueries ?? [];\n const invalidateQueries = options?.invalidateQueries ?? [];\n const onSuccess = options?.onSuccess;\n const onError = options?.onError;\n const args = options?.args ?? [];\n\n // Using a custom hook to manage state specific to asynchronous operations\n const {\n setIsFetched,\n setIsLoading,\n setError,\n setIsSuccess,\n setData,\n setIsInvalidated,\n setIsEnabled,\n incrementRetryCount,\n resetRetryCount,\n } = useAsyncStateStore(\n useShallow((state) => ({\n setIsFetched: state.setIsFetched,\n setIsLoading: state.setIsLoading,\n setError: state.setError,\n setIsSuccess: state.setIsSuccess,\n setIsInvalidated: state.setIsInvalidated,\n setIsEnabled: state.setIsEnabled,\n setData: state.setData,\n incrementRetryCount: state.incrementRetryCount,\n resetRetryCount: state.resetRetryCount,\n }))\n );\n\n // Storing the last arguments used to call the async function\n const storedArgsRef = useRef<any>(args ?? []);\n\n // Apply different key for different requests\n const keyWithArgs = getKeyWithArgs(key, storedArgsRef.current);\n\n // Retrieving the current state of async operations using the same custom hook\n const {\n isFetched,\n fetchedDateTime,\n isLoading,\n isEnabled: isEnabledState,\n error,\n isSuccess,\n isInvalidated,\n data,\n retryCount: errorCount,\n } = useAsyncStateStore((state) => state.getStates(keyWithArgs));\n\n const isEnabled = isEnabledState || enabled;\n const isDisabled = !isEnabled;\n\n // The core fetching function, designed to be called directly or automatically based on configuration\n const fetch: T = useCallback<T>(\n (async (...args) => {\n const keyWithArgs = getKeyWithArgs(key, args);\n\n if (pendingPromises.has(keyWithArgs)) {\n // Return the existing pending promise\n return pendingPromises.get(keyWithArgs);\n }\n\n const promise = (async () => {\n setIsLoading(keyWithArgs, true);\n let response = null;\n let errorResponse = null;\n\n await asyncFunction(...args)\n .then((result) => {\n const isResultChanged =\n JSON.stringify(result) !== JSON.stringify(data);\n\n response = result;\n if (isResultChanged) {\n setData(keyWithArgs, result);\n }\n setIsSuccess(keyWithArgs, true);\n onSuccess?.(result);\n resetRetryCount(keyWithArgs);\n\n // Store the result in session storage\n if (storeEnabled) {\n sessionStorage.setItem(keyWithArgs, JSON.stringify(result));\n }\n\n // Update other queries if necessary\n if (isResultChanged && updateQueries.length > 0) {\n updateQueries.forEach((key) => {\n setData(key, result);\n });\n }\n\n // Invalidate other queries if necessary\n if (isResultChanged && invalidateQueries.length > 0) {\n invalidateQueries.forEach((key) => {\n setIsInvalidated(key, true);\n });\n }\n })\n .catch((error) => {\n const errorMessage = error.message ?? 'An error occurred';\n\n setData(keyWithArgs, null);\n setError(keyWithArgs, errorMessage);\n incrementRetryCount(keyWithArgs);\n onError?.(errorMessage);\n errorResponse = error;\n })\n .finally(() => {\n setIsLoading(keyWithArgs, false);\n setIsFetched(keyWithArgs, true);\n setIsInvalidated(keyWithArgs, false);\n\n // Remove the pending promise from the cache\n pendingPromises.delete(keyWithArgs);\n });\n\n if (errorResponse) {\n throw new Error(errorResponse);\n }\n\n return response;\n })();\n\n // Store the pending promise in the cache\n pendingPromises.set(keyWithArgs, promise);\n }) as T,\n [asyncFunction, keyWithArgs]\n );\n\n // Wrapped execution function to handle disabled state and check for success before re-fetching\n const execute: T = useCallback<T>(\n (async (...args) => {\n if (isDisabled) return;\n if (isLoading) return;\n if (isSuccess && cacheEnabled && data) return data;\n\n if (args) {\n storedArgsRef.current = args;\n }\n\n await fetch(...args);\n }) as T,\n [isDisabled, cacheEnabled, isSuccess, data, isLoading]\n );\n\n // Function to revalidate the data when necessary\n const revalidate: T = useCallback<T>(\n (async (...args) => {\n if (isDisabled) return;\n if (isSuccess) return;\n if (isLoading) return;\n\n if (args) {\n storedArgsRef.current = args;\n }\n\n await fetch(...storedArgsRef.current);\n }) as T,\n [isDisabled, storedArgsRef, isSuccess, isLoading]\n );\n\n const autoRevalidate = useCallback(() => {\n if (isDisabled) return;\n if (isLoading || !(cacheEnabled || storeEnabled)) return;\n if (!revalidationEnabled || revalidateTime <= 0 || !isSuccess) return;\n if (!fetchedDateTime) return;\n\n const now = new Date().getTime();\n const lastFetchedTime = new Date(fetchedDateTime).getTime();\n const shouldRevalidate = now - lastFetchedTime >= revalidateTime;\n if (shouldRevalidate) {\n fetch(...storedArgsRef.current);\n }\n }, [\n cacheEnabled,\n revalidationEnabled,\n revalidateTime,\n isSuccess,\n fetchedDateTime,\n isLoading,\n isDisabled,\n ]);\n\n useEffect(() => {\n setIsEnabled(keyWithArgs, enabled);\n }, [enabled]);\n\n // Auto-fetch data on hook mount if autoFetch is true\n useEffect(() => {\n if (!autoFetch) return;\n if (isDisabled) return;\n if (isFetched || isLoading) return;\n\n fetch(...storedArgsRef.current);\n }, [autoFetch, isFetched, isDisabled, isLoading]);\n\n // Handle retry based on conditions set in options\n useEffect(() => {\n const isRetryEnabled = errorCount > 0 && retryLimit > 0;\n const isRetryLimitReached = errorCount >= retryLimit;\n if (isDisabled) return;\n if (!(cacheEnabled || storeEnabled)) return;\n if (!isRetryEnabled || isRetryLimitReached) return;\n if (isSuccess) return;\n if (isLoading) return;\n\n const timeOut = setTimeout(() => {\n if (isRetryEnabled && !isRetryLimitReached && !isSuccess) {\n execute(...storedArgsRef.current);\n }\n }, retryTime);\n\n return () => clearTimeout(timeOut);\n }, [execute, errorCount, retryLimit, retryTime, isSuccess]);\n\n // Handle periodic revalidation if caching is enabled\n useEffect(() => {\n const interval = setInterval(autoRevalidate, revalidateTime);\n\n return () => clearInterval(interval);\n }, [autoRevalidate, revalidateTime]);\n\n // Load data from session storage if storeEnabled is true\n useEffect(() => {\n if (isDisabled) return;\n if (!storeEnabled) return;\n if (isInvalidated) return;\n if (isFetched) return;\n\n const storedData = sessionStorage.getItem(keyWithArgs);\n\n if (storedData) {\n setData(keyWithArgs, JSON.parse(storedData));\n }\n }, [storeEnabled, keyWithArgs, isFetched, isInvalidated, isDisabled]);\n\n // Handle invalidation if props are changed\n useEffect(() => {\n if (!isInvalidatedProps) return;\n setIsInvalidated(keyWithArgs, isInvalidatedProps);\n }, [isInvalidatedProps]);\n\n // Memoization of the setData function to prevent unnecessary re-renders\n const setDataMemo = useCallback(\n (data: Awaited<ReturnType<T> | null>) => {\n setData(keyWithArgs, data);\n },\n [keyWithArgs]\n );\n\n // Return the hook's result, including all state and control functions\n return {\n isFetched,\n isLoading,\n isInvalidated,\n error,\n isSuccess,\n data,\n retryCount: errorCount,\n isDisabled,\n isEnabled,\n [key]: execute,\n revalidate,\n setData: setDataMemo,\n } as UseAsyncResultBase<T> & Record<U, T>;\n};\n"],"names":["ReactExports","useAsyncStateStore","useRef","useCallback","args","keyWithArgs","key","error","useEffect","data"],"mappings":";;;;;AAEA,SAAS,QAAQ,MAAM,MAAM;AAC3B,MAAI,OAAO,GAAG,MAAM,IAAI,GAAG;AACzB,WAAO;AAAA,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AAe,UAAU,CAAC;AAGpEA,aAAAA,UAAU,MAAM;AACd,QAAI,CAAC,mBAAoB;AACzB,qBAAiB,aAAa,kBAAkB;AAAA,EAAA,GAC/C,CAAC,kBAAkB,CAAC;AAGvB,QAAM,cAAcL,WAAA;AAAA,IAClB,CAACM,UAAwC;AACvC,cAAQ,aAAaA,KAAI;AAAA,IAC3B;AAAA,IACA,CAAC,WAAW;AAAA,EAAA;AAIP,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA,CAAC,GAAG,GAAG;AAAA,IACP;AAAA,IACA,SAAS;AAAA,EAAA;AAEb;;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"useAsync.cjs","sources":["../../../../../../node_modules/.pnpm/zustand@4.5.5_@types+react@18.3.12_react@18.3.1/node_modules/zustand/esm/react/shallow.mjs","../../../src/hooks/useAsync/useAsync.ts"],"sourcesContent":["import ReactExports from 'react';\n\nfunction shallow(objA, objB) {\n if (Object.is(objA, objB)) {\n return true;\n }\n if (typeof objA !== \"object\" || objA === null || typeof objB !== \"object\" || objB === null) {\n return false;\n }\n if (objA instanceof Map && objB instanceof Map) {\n if (objA.size !== objB.size) return false;\n for (const [key, value] of objA) {\n if (!Object.is(value, objB.get(key))) {\n return false;\n }\n }\n return true;\n }\n if (objA instanceof Set && objB instanceof Set) {\n if (objA.size !== objB.size) return false;\n for (const value of objA) {\n if (!objB.has(value)) {\n return false;\n }\n }\n return true;\n }\n const keysA = Object.keys(objA);\n if (keysA.length !== Object.keys(objB).length) {\n return false;\n }\n for (const keyA of keysA) {\n if (!Object.prototype.hasOwnProperty.call(objB, keyA) || !Object.is(objA[keyA], objB[keyA])) {\n return false;\n }\n }\n return true;\n}\n\nconst { useRef } = ReactExports;\nfunction useShallow(selector) {\n const prev = useRef();\n return (state) => {\n const next = selector(state);\n return shallow(prev.current, next) ? prev.current : prev.current = next;\n };\n}\n\nexport { useShallow };\n","'use client';\n\n// This is an ESLint directive to disable specific rules.\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { useCallback, useEffect, useRef } from 'react';\nimport { useShallow } from 'zustand/react/shallow';\nimport { useAsyncStateStore } from './useAsyncStateStore';\n\n// Pending promises cache to prevent parallel requests when multiple components use the hook\nconst pendingPromises = new Map();\n\n// Defines the base structure for the result of the custom hook.\ntype UseAsyncResultBase<T extends (...args: any[]) => Promise<any>> = {\n isFetched: boolean;\n isLoading: boolean;\n isInvalidated: boolean;\n isSuccess: boolean;\n isDisabled: boolean;\n error: string | null;\n data: Awaited<ReturnType<T>> | null;\n retryCount: number;\n revalidate: T;\n setData: (data: Awaited<ReturnType<T> | null>) => void;\n};\n\n// Options type for the hook, allowing customization of behavior.\nexport type UseAsyncOptions<T extends (...args: any[]) => Promise<any>> = {\n retryLimit?: number; // The number of times the hook should retry the function on failure before giving up\n retryTime?: number; // Time in milliseconds for retrying the data\n cache?: boolean; // Cache the result of the function using zustand\n store?: boolean; // Store the result of the function in session storage\n enable?: boolean; // Enable the hook\n autoFetch?: boolean; // Automatically fetch the data when the hook is mounted\n revalidation?: boolean; // Enable revalidation\n revalidateTime?: number; // Time in milliseconds for revalidating the data\n isInvalidated?: boolean; // Determine if the data is invalidated and should be refetched\n invalidateQueries?: string[]; // Invalidate other queries when the data is updated\n updateQueries?: string[]; // Update other queries when the data is updated\n onSuccess?: (data: Awaited<ReturnType<T>>) => void; // Callback function that is called when the asynchronous function resolves successfully\n onError?: (error: string) => void; // Callback function that is called when the asynchronous function rejects or encounters an error\n args?: Parameters<T>; // Arguments to pass to the asynchronous function\n};\n\n// Default values for the hook's options\nconst DEFAULT_CACHE_ENABLED = false;\nconst DEFAULT_STORE_ENABLED = false;\nconst DEFAULT_ENABLED = true;\nconst DEFAULT_AUTO_FETCH = false;\nconst DEFAULT_RETRY_LIMIT = 1;\nconst DEFAULT_REVALIDATION_ENABLED = false;\nconst DEFAULT_REVALIDATE_TIME = 5 * 60 * 1000; // 5 minutes\nconst DEFAULT_RETRY_TIME = 5 * 60 * 1000; // 5 minutes\n\n// The main hook type that includes the async function along with its additional properties.\nexport type UseAsyncResult<\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n> = UseAsyncResultBase<T> & Record<U, T>;\n\nconst getKeyWithArgs = (key: string, args: any[]) =>\n args.length > 0 ? `${key}/${JSON.stringify(args)}` : key;\n\n/**\n * A custom React hook that manages asynchronous operations, providing easy-to-use states and controls over fetching, caching, and retry mechanisms.\n * This hook abstracts away the complexity of handling loading, error, and success states for any asynchronous function.\n *\n * @template U - A string type that extends the keys of the async function, used as a key to store and retrieve state.\n * @template T - A function type that must return a Promise, representing the asynchronous operation to be managed.\n *\n * @param {U} key - A unique identifier for the async operation, used to handle state internally and avoid conflicts.\n * @param {T} asyncFunction - The asynchronous function that will be managed by this hook. This function should return a Promise.\n * @param {UseAsyncOptions<T>} [options] - Optional configuration options to customize the behavior of the hook.\n * @returns {UseAsyncResult<U, T>} The states and controls related to the managed async function. Includes states like isLoading, isSuccess, and provides control methods like revalidate and setData.\n *\n * @typedef {Object} UseAsyncOptions\n * @property {number} [retryTime=300000] - Time in milliseconds for retrying the data after an error occurs.\n * @property {number} [retryLimit=1] - The number of times the hook should retry the asynchronous function on failure before giving up.\n * @property {boolean} [revalidation=false] - Enable revalidation.\n * @property {number} [revalidateTime=300000] - Time in milliseconds after which the cached data is considered stale and the async function is re-invoked, if caching is enabled.\n * @property {boolean} [cache=false] - Whether to cache the result of the async function. When enabled, revalidation is controlled by `revalidateTime`.\n * @property {boolean} [store=false] - Store the result of the function in session storage.\n * @property {boolean} [autoFetch=false] - Whether the hook should automatically invoke the asynchronous function on mount.\n * @property {number} [revalidateTime=300000] - Time in milliseconds after which the cached data is considered stale and the async function is re-invoked, if caching is enabled.\n * @property {boolean} [isInvalidated=false] - Determine if the data is invalidated and should be refetched.\n * @property {string[]} [updateQueries=[]] - Update other queries when the data is updated.\n * @property {string[]} [invalidateQueries=[]] - Invalidate other queries when the data is updated.\n * @property {(data: Awaited<ReturnType<T>>) => void} [onSuccess] - Callback function that is called when the asynchronous function resolves successfully.\n * @property {(error: string) => void} [onError] - Callback function that is called when the asynchronous function rejects or encounters an error.\n * @property {Parameters<T>} [args=[]] - Arguments to pass to the asynchronous function.\n *\n *\n * @example\n * // Example of using useAsync to manage fetching user data from an API.\n * const fetchUserData = async (userId) => {\n * const response = await fetch(`/api/users/${userId}`);\n * if (!response.ok) throw new Error('Failed to fetch');\n * return await response.json();\n * };\n *\n * const UserDetails = ({ userId }) => {\n * const {\n * isLoading,\n * data,\n * error,\n * revalidate,\n * } = useAsync('userDetails', fetchUserData, {\n * cache: true,\n * revalidateTime: 60000, // 1 minute\n * autoFetch: true,\n * onSuccess: (data) => console.log('User data fetched successfully:', data),\n * onError: (error) => console.error('Error fetching user data:', error),\n * });\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error}</div>;\n * return (\n * <div>\n * <h1>{data.name}</h1>\n * <button onClick={() => revalidate()}>Refresh</button>\n * </div>\n * );\n * };\n */\nexport const useAsync = <\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n>(\n key: U,\n asyncFunction: T,\n options?: UseAsyncOptions<T>\n): UseAsyncResult<U, T> => {\n // Resolving optional parameters with default values\n const retryLimit = options?.retryLimit ?? DEFAULT_RETRY_LIMIT;\n const autoFetch = options?.autoFetch ?? DEFAULT_AUTO_FETCH;\n const retryTime = options?.retryTime ?? DEFAULT_RETRY_TIME;\n const cacheEnabled = options?.cache ?? DEFAULT_CACHE_ENABLED;\n const storeEnabled = options?.store ?? DEFAULT_STORE_ENABLED;\n const enabled = options?.enable ?? DEFAULT_ENABLED;\n const revalidationEnabled =\n options?.revalidation ?? DEFAULT_REVALIDATION_ENABLED;\n const revalidateTime = options?.revalidateTime ?? DEFAULT_REVALIDATE_TIME;\n const isInvalidatedProps = options?.isInvalidated ?? false;\n const updateQueries = options?.updateQueries ?? [];\n const invalidateQueries = options?.invalidateQueries ?? [];\n const onSuccess = options?.onSuccess;\n const onError = options?.onError;\n const args = options?.args ?? [];\n\n // Using a custom hook to manage state specific to asynchronous operations\n const {\n setIsFetched,\n setIsLoading,\n setError,\n setIsSuccess,\n setData,\n setIsInvalidated,\n setIsEnabled,\n incrementRetryCount,\n resetRetryCount,\n } = useAsyncStateStore(\n useShallow((state) => ({\n setIsFetched: state.setIsFetched,\n setIsLoading: state.setIsLoading,\n setError: state.setError,\n setIsSuccess: state.setIsSuccess,\n setIsInvalidated: state.setIsInvalidated,\n setIsEnabled: state.setIsEnabled,\n setData: state.setData,\n incrementRetryCount: state.incrementRetryCount,\n resetRetryCount: state.resetRetryCount,\n }))\n );\n\n // Storing the last arguments used to call the async function\n const storedArgsRef = useRef<any>(args ?? []);\n\n // Apply different key for different requests\n const keyWithArgs = getKeyWithArgs(key, storedArgsRef.current);\n\n // Retrieving the current state of async operations using the same custom hook\n const {\n isFetched,\n fetchedDateTime,\n isLoading,\n isEnabled: isEnabledState,\n error,\n isSuccess,\n isInvalidated,\n data,\n retryCount: errorCount,\n } = useAsyncStateStore((state) => state.getStates(keyWithArgs));\n\n const isEnabled = isEnabledState || enabled;\n const isDisabled = !isEnabled;\n\n // The core fetching function, designed to be called directly or automatically based on configuration\n const fetch: T = useCallback<T>(\n (async (...args) => {\n const keyWithArgs = getKeyWithArgs(key, args);\n\n if (pendingPromises.has(keyWithArgs)) {\n // Return the existing pending promise\n return pendingPromises.get(keyWithArgs);\n }\n\n const promise = (async () => {\n setIsLoading(keyWithArgs, true);\n let response = null;\n let errorResponse = null;\n\n await asyncFunction(...args)\n .then((result) => {\n const isResultChanged =\n JSON.stringify(result) !== JSON.stringify(data);\n\n response = result;\n if (isResultChanged) {\n setData(keyWithArgs, result);\n }\n setIsSuccess(keyWithArgs, true);\n onSuccess?.(result);\n resetRetryCount(keyWithArgs);\n\n // Store the result in session storage\n if (storeEnabled) {\n sessionStorage.setItem(keyWithArgs, JSON.stringify(result));\n }\n\n // Update other queries if necessary\n if (isResultChanged && updateQueries.length > 0) {\n updateQueries.forEach((key) => {\n setData(key, result);\n });\n }\n\n // Invalidate other queries if necessary\n if (isResultChanged && invalidateQueries.length > 0) {\n invalidateQueries.forEach((key) => {\n setIsInvalidated(key, true);\n });\n }\n })\n .catch((error) => {\n const errorMessage = error.message ?? 'An error occurred';\n console.error(JSON.stringify(error));\n\n setData(keyWithArgs, null);\n setError(keyWithArgs, errorMessage);\n incrementRetryCount(keyWithArgs);\n onError?.(errorMessage);\n errorResponse = error;\n })\n .finally(() => {\n setIsLoading(keyWithArgs, false);\n setIsFetched(keyWithArgs, true);\n setIsInvalidated(keyWithArgs, false);\n\n // Remove the pending promise from the cache\n pendingPromises.delete(keyWithArgs);\n });\n\n return response;\n })();\n\n // Store the pending promise in the cache\n pendingPromises.set(keyWithArgs, promise);\n }) as T,\n [asyncFunction, keyWithArgs]\n );\n\n // Wrapped execution function to handle disabled state and check for success before re-fetching\n const execute: T = useCallback<T>(\n (async (...args) => {\n if (isDisabled) return;\n if (isLoading) return;\n if (isSuccess && cacheEnabled && data) return data;\n\n if (args) {\n storedArgsRef.current = args;\n }\n\n await fetch(...args);\n }) as T,\n [isDisabled, cacheEnabled, isSuccess, data, isLoading]\n );\n\n // Function to revalidate the data when necessary\n const revalidate: T = useCallback<T>(\n (async (...args) => {\n if (isDisabled) return;\n if (isSuccess) return;\n if (isLoading) return;\n\n if (args) {\n storedArgsRef.current = args;\n }\n\n await fetch(...storedArgsRef.current);\n }) as T,\n [isDisabled, storedArgsRef, isSuccess, isLoading]\n );\n\n const autoRevalidate = useCallback(() => {\n if (isDisabled) return;\n if (isLoading || !(cacheEnabled || storeEnabled)) return;\n if (!revalidationEnabled || revalidateTime <= 0 || !isSuccess) return;\n if (!fetchedDateTime) return;\n\n const now = new Date().getTime();\n const lastFetchedTime = new Date(fetchedDateTime).getTime();\n const shouldRevalidate = now - lastFetchedTime >= revalidateTime;\n if (shouldRevalidate) {\n fetch(...storedArgsRef.current);\n }\n }, [\n cacheEnabled,\n revalidationEnabled,\n revalidateTime,\n isSuccess,\n fetchedDateTime,\n isLoading,\n isDisabled,\n ]);\n\n useEffect(() => {\n setIsEnabled(keyWithArgs, enabled);\n }, [enabled]);\n\n // Auto-fetch data on hook mount if autoFetch is true\n useEffect(() => {\n if (!autoFetch) return;\n if (isDisabled) return;\n if (isFetched || isLoading) return;\n\n fetch(...storedArgsRef.current);\n }, [autoFetch, isFetched, isDisabled, isLoading]);\n\n // Handle retry based on conditions set in options\n useEffect(() => {\n const isRetryEnabled = errorCount > 0 && retryLimit > 0;\n const isRetryLimitReached = errorCount >= retryLimit;\n if (isDisabled) return;\n if (!(cacheEnabled || storeEnabled)) return;\n if (!isRetryEnabled || isRetryLimitReached) return;\n if (isSuccess) return;\n if (isLoading) return;\n\n const timeOut = setTimeout(() => {\n if (isRetryEnabled && !isRetryLimitReached && !isSuccess) {\n execute(...storedArgsRef.current);\n }\n }, retryTime);\n\n return () => clearTimeout(timeOut);\n }, [execute, errorCount, retryLimit, retryTime, isSuccess]);\n\n // Handle periodic revalidation if caching is enabled\n useEffect(() => {\n const interval = setInterval(autoRevalidate, revalidateTime);\n\n return () => clearInterval(interval);\n }, [autoRevalidate, revalidateTime]);\n\n // Load data from session storage if storeEnabled is true\n useEffect(() => {\n if (isDisabled) return;\n if (!storeEnabled) return;\n if (isInvalidated) return;\n if (isFetched) return;\n\n const storedData = sessionStorage.getItem(keyWithArgs);\n\n if (storedData) {\n setData(keyWithArgs, JSON.parse(storedData));\n }\n }, [storeEnabled, keyWithArgs, isFetched, isInvalidated, isDisabled]);\n\n // Handle invalidation if props are changed\n useEffect(() => {\n if (!isInvalidatedProps) return;\n setIsInvalidated(keyWithArgs, isInvalidatedProps);\n }, [isInvalidatedProps]);\n\n // Memoization of the setData function to prevent unnecessary re-renders\n const setDataMemo = useCallback(\n (data: Awaited<ReturnType<T> | null>) => {\n setData(keyWithArgs, data);\n },\n [keyWithArgs]\n );\n\n // Return the hook's result, including all state and control functions\n return {\n isFetched,\n isLoading,\n isInvalidated,\n error,\n isSuccess,\n data,\n retryCount: errorCount,\n isDisabled,\n isEnabled,\n [key]: execute,\n revalidate,\n setData: setDataMemo,\n } as UseAsyncResultBase<T> & Record<U, T>;\n};\n"],"names":["ReactExports","useAsyncStateStore","useRef","useCallback","args","keyWithArgs","key","error","useEffect","data"],"mappings":";;;;;AAEA,SAAS,QAAQ,MAAM,MAAM;AAC3B,MAAI,OAAO,GAAG,MAAM,IAAI,GAAG;AACzB,WAAO;AAAA,EACR;AACD,MAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,OAAO,SAAS,YAAY,SAAS,MAAM;AAC1F,WAAO;AAAA,EACR;AACD,MAAI,gBAAgB,OAAO,gBAAgB,KAAK;AAC9C,QAAI,KAAK,SAAS,KAAK,KAAM,QAAO;AACpC,eAAW,CAAC,KAAK,KAAK,KAAK,MAAM;AAC/B,UAAI,CAAC,OAAO,GAAG,OAAO,KAAK,IAAI,GAAG,CAAC,GAAG;AACpC,eAAO;AAAA,MACR;AAAA,IACF;AACD,WAAO;AAAA,EACR;AACD,MAAI,gBAAgB,OAAO,gBAAgB,KAAK;AAC9C,QAAI,KAAK,SAAS,KAAK,KAAM,QAAO;AACpC,eAAW,SAAS,MAAM;AACxB,UAAI,CAAC,KAAK,IAAI,KAAK,GAAG;AACpB,eAAO;AAAA,MACR;AAAA,IACF;AACD,WAAO;AAAA,EACR;AACD,QAAM,QAAQ,OAAO,KAAK,IAAI;AAC9B,MAAI,MAAM,WAAW,OAAO,KAAK,IAAI,EAAE,QAAQ;AAC7C,WAAO;AAAA,EACR;AACD,aAAW,QAAQ,OAAO;AACxB,QAAI,CAAC,OAAO,UAAU,eAAe,KAAK,MAAM,IAAI,KAAK,CAAC,OAAO,GAAG,KAAK,IAAI,GAAG,KAAK,IAAI,CAAC,GAAG;AAC3F,aAAO;AAAA,IACR;AAAA,EACF;AACD,SAAO;AACT;AAEA,MA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AQ;AAAA,EAAA,GAClC,CAAC,gBAAgB,cAAc,CAAC;AAGnCA,aAAAA,UAAU,MAAM;AACd,QAAI,WAAY;AAChB,QAAI,CAAC,aAAc;AACnB,QAAI,cAAe;AACnB,QAAI,UAAW;AAET,UAAA,aAAa,eAAe,QAAQ,WAAW;AAErD,QAAI,YAAY;AACd,cAAQ,aAAa,KAAK,MAAM,UAAU,CAAC;AAAA,IAC7C;AAAA,EAAA,GACC,CAAC,cAAc,aAAa,WAAW,eAAe,UAAU,CAAC;AAGpEA,aAAAA,UAAU,MAAM;AACd,QAAI,CAAC,mBAAoB;AACzB,qBAAiB,aAAa,kBAAkB;AAAA,EAAA,GAC/C,CAAC,kBAAkB,CAAC;AAGvB,QAAM,cAAcL,WAAA;AAAA,IAClB,CAACM,UAAwC;AACvC,cAAQ,aAAaA,KAAI;AAAA,IAC3B;AAAA,IACA,CAAC,WAAW;AAAA,EAAA;AAIP,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA,CAAC,GAAG,GAAG;AAAA,IACP;AAAA,IACA,SAAS;AAAA,EAAA;AAEb;;","x_google_ignoreList":[0]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAsync.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAsync/useAsync.ts"],"names":[],"mappings":"AAaA,KAAK,kBAAkB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,IAAI;IACpE,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,IAAI,EAAE,OAAO,CAAC,UA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AAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACnD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,IAAI,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;CACtB,CAAC;AAaF,MAAM,MAAM,cAAc,CACxB,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,IACxC,kBAAkB,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAKzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,eAAO,MAAM,QAAQ,GACnB,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,OAErC,CAAC,iBACS,CAAC,YACN,eAAe,CAAC,CAAC,CAAC,KAC3B,cAAc,CAAC,CAAC,EAAE,CAAC,CAoRrB,CAAC"}
|
|
@@ -117,7 +117,6 @@ const useAsync = (key, asyncFunction, options) => {
|
|
|
117
117
|
const promise = (async () => {
|
|
118
118
|
setIsLoading(keyWithArgs2, true);
|
|
119
119
|
let response = null;
|
|
120
|
-
let errorResponse = null;
|
|
121
120
|
await asyncFunction(...args2).then((result) => {
|
|
122
121
|
const isResultChanged = JSON.stringify(result) !== JSON.stringify(data);
|
|
123
122
|
response = result;
|
|
@@ -142,20 +141,17 @@ const useAsync = (key, asyncFunction, options) => {
|
|
|
142
141
|
}
|
|
143
142
|
}).catch((error2) => {
|
|
144
143
|
const errorMessage = error2.message ?? "An error occurred";
|
|
144
|
+
console.error(JSON.stringify(error2));
|
|
145
145
|
setData(keyWithArgs2, null);
|
|
146
146
|
setError(keyWithArgs2, errorMessage);
|
|
147
147
|
incrementRetryCount(keyWithArgs2);
|
|
148
148
|
onError?.(errorMessage);
|
|
149
|
-
errorResponse = error2;
|
|
150
149
|
}).finally(() => {
|
|
151
150
|
setIsLoading(keyWithArgs2, false);
|
|
152
151
|
setIsFetched(keyWithArgs2, true);
|
|
153
152
|
setIsInvalidated(keyWithArgs2, false);
|
|
154
153
|
pendingPromises.delete(keyWithArgs2);
|
|
155
154
|
});
|
|
156
|
-
if (errorResponse) {
|
|
157
|
-
throw new Error(errorResponse);
|
|
158
|
-
}
|
|
159
155
|
return response;
|
|
160
156
|
})();
|
|
161
157
|
pendingPromises.set(keyWithArgs2, promise);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAsync.mjs","sources":["../../../../../../node_modules/.pnpm/zustand@4.5.5_@types+react@18.3.11_react@18.3.1/node_modules/zustand/esm/react/shallow.mjs","../../../src/hooks/useAsync/useAsync.ts"],"sourcesContent":["import ReactExports from 'react';\n\nfunction shallow(objA, objB) {\n if (Object.is(objA, objB)) {\n return true;\n }\n if (typeof objA !== \"object\" || objA === null || typeof objB !== \"object\" || objB === null) {\n return false;\n }\n if (objA instanceof Map && objB instanceof Map) {\n if (objA.size !== objB.size) return false;\n for (const [key, value] of objA) {\n if (!Object.is(value, objB.get(key))) {\n return false;\n }\n }\n return true;\n }\n if (objA instanceof Set && objB instanceof Set) {\n if (objA.size !== objB.size) return false;\n for (const value of objA) {\n if (!objB.has(value)) {\n return false;\n }\n }\n return true;\n }\n const keysA = Object.keys(objA);\n if (keysA.length !== Object.keys(objB).length) {\n return false;\n }\n for (const keyA of keysA) {\n if (!Object.prototype.hasOwnProperty.call(objB, keyA) || !Object.is(objA[keyA], objB[keyA])) {\n return false;\n }\n }\n return true;\n}\n\nconst { useRef } = ReactExports;\nfunction useShallow(selector) {\n const prev = useRef();\n return (state) => {\n const next = selector(state);\n return shallow(prev.current, next) ? prev.current : prev.current = next;\n };\n}\n\nexport { useShallow };\n","'use client';\n\n// This is an ESLint directive to disable specific rules.\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { useCallback, useEffect, useRef } from 'react';\nimport { useShallow } from 'zustand/react/shallow';\nimport { useAsyncStateStore } from './useAsyncStateStore';\n\n// Pending promises cache to prevent parallel requests when multiple components use the hook\nconst pendingPromises = new Map();\n\n// Defines the base structure for the result of the custom hook.\ntype UseAsyncResultBase<T extends (...args: any[]) => Promise<any>> = {\n isFetched: boolean;\n isLoading: boolean;\n isInvalidated: boolean;\n isSuccess: boolean;\n isDisabled: boolean;\n error: string | null;\n data: Awaited<ReturnType<T>> | null;\n retryCount: number;\n revalidate: T;\n setData: (data: Awaited<ReturnType<T> | null>) => void;\n};\n\n// Options type for the hook, allowing customization of behavior.\nexport type UseAsyncOptions<T extends (...args: any[]) => Promise<any>> = {\n retryLimit?: number; // The number of times the hook should retry the function on failure before giving up\n retryTime?: number; // Time in milliseconds for retrying the data\n cache?: boolean; // Cache the result of the function using zustand\n store?: boolean; // Store the result of the function in session storage\n enable?: boolean; // Enable the hook\n autoFetch?: boolean; // Automatically fetch the data when the hook is mounted\n revalidation?: boolean; // Enable revalidation\n revalidateTime?: number; // Time in milliseconds for revalidating the data\n isInvalidated?: boolean; // Determine if the data is invalidated and should be refetched\n invalidateQueries?: string[]; // Invalidate other queries when the data is updated\n updateQueries?: string[]; // Update other queries when the data is updated\n onSuccess?: (data: Awaited<ReturnType<T>>) => void; // Callback function that is called when the asynchronous function resolves successfully\n onError?: (error: string) => void; // Callback function that is called when the asynchronous function rejects or encounters an error\n args?: Parameters<T>; // Arguments to pass to the asynchronous function\n};\n\n// Default values for the hook's options\nconst DEFAULT_CACHE_ENABLED = false;\nconst DEFAULT_STORE_ENABLED = false;\nconst DEFAULT_ENABLED = true;\nconst DEFAULT_AUTO_FETCH = false;\nconst DEFAULT_RETRY_LIMIT = 1;\nconst DEFAULT_REVALIDATION_ENABLED = false;\nconst DEFAULT_REVALIDATE_TIME = 5 * 60 * 1000; // 5 minutes\nconst DEFAULT_RETRY_TIME = 5 * 60 * 1000; // 5 minutes\n\n// The main hook type that includes the async function along with its additional properties.\nexport type UseAsyncResult<\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n> = UseAsyncResultBase<T> & Record<U, T>;\n\nconst getKeyWithArgs = (key: string, args: any[]) =>\n args.length > 0 ? `${key}/${JSON.stringify(args)}` : key;\n\n/**\n * A custom React hook that manages asynchronous operations, providing easy-to-use states and controls over fetching, caching, and retry mechanisms.\n * This hook abstracts away the complexity of handling loading, error, and success states for any asynchronous function.\n *\n * @template U - A string type that extends the keys of the async function, used as a key to store and retrieve state.\n * @template T - A function type that must return a Promise, representing the asynchronous operation to be managed.\n *\n * @param {U} key - A unique identifier for the async operation, used to handle state internally and avoid conflicts.\n * @param {T} asyncFunction - The asynchronous function that will be managed by this hook. This function should return a Promise.\n * @param {UseAsyncOptions<T>} [options] - Optional configuration options to customize the behavior of the hook.\n * @returns {UseAsyncResult<U, T>} The states and controls related to the managed async function. Includes states like isLoading, isSuccess, and provides control methods like revalidate and setData.\n *\n * @typedef {Object} UseAsyncOptions\n * @property {number} [retryTime=300000] - Time in milliseconds for retrying the data after an error occurs.\n * @property {number} [retryLimit=1] - The number of times the hook should retry the asynchronous function on failure before giving up.\n * @property {boolean} [revalidation=false] - Enable revalidation.\n * @property {number} [revalidateTime=300000] - Time in milliseconds after which the cached data is considered stale and the async function is re-invoked, if caching is enabled.\n * @property {boolean} [cache=false] - Whether to cache the result of the async function. When enabled, revalidation is controlled by `revalidateTime`.\n * @property {boolean} [store=false] - Store the result of the function in session storage.\n * @property {boolean} [autoFetch=false] - Whether the hook should automatically invoke the asynchronous function on mount.\n * @property {number} [revalidateTime=300000] - Time in milliseconds after which the cached data is considered stale and the async function is re-invoked, if caching is enabled.\n * @property {boolean} [isInvalidated=false] - Determine if the data is invalidated and should be refetched.\n * @property {string[]} [updateQueries=[]] - Update other queries when the data is updated.\n * @property {string[]} [invalidateQueries=[]] - Invalidate other queries when the data is updated.\n * @property {(data: Awaited<ReturnType<T>>) => void} [onSuccess] - Callback function that is called when the asynchronous function resolves successfully.\n * @property {(error: string) => void} [onError] - Callback function that is called when the asynchronous function rejects or encounters an error.\n * @property {Parameters<T>} [args=[]] - Arguments to pass to the asynchronous function.\n *\n *\n * @example\n * // Example of using useAsync to manage fetching user data from an API.\n * const fetchUserData = async (userId) => {\n * const response = await fetch(`/api/users/${userId}`);\n * if (!response.ok) throw new Error('Failed to fetch');\n * return await response.json();\n * };\n *\n * const UserDetails = ({ userId }) => {\n * const {\n * isLoading,\n * data,\n * error,\n * revalidate,\n * } = useAsync('userDetails', fetchUserData, {\n * cache: true,\n * revalidateTime: 60000, // 1 minute\n * autoFetch: true,\n * onSuccess: (data) => console.log('User data fetched successfully:', data),\n * onError: (error) => console.error('Error fetching user data:', error),\n * });\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error}</div>;\n * return (\n * <div>\n * <h1>{data.name}</h1>\n * <button onClick={() => revalidate()}>Refresh</button>\n * </div>\n * );\n * };\n */\nexport const useAsync = <\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n>(\n key: U,\n asyncFunction: T,\n options?: UseAsyncOptions<T>\n): UseAsyncResult<U, T> => {\n // Resolving optional parameters with default values\n const retryLimit = options?.retryLimit ?? DEFAULT_RETRY_LIMIT;\n const autoFetch = options?.autoFetch ?? DEFAULT_AUTO_FETCH;\n const retryTime = options?.retryTime ?? DEFAULT_RETRY_TIME;\n const cacheEnabled = options?.cache ?? DEFAULT_CACHE_ENABLED;\n const storeEnabled = options?.store ?? DEFAULT_STORE_ENABLED;\n const enabled = options?.enable ?? DEFAULT_ENABLED;\n const revalidationEnabled =\n options?.revalidation ?? DEFAULT_REVALIDATION_ENABLED;\n const revalidateTime = options?.revalidateTime ?? DEFAULT_REVALIDATE_TIME;\n const isInvalidatedProps = options?.isInvalidated ?? false;\n const updateQueries = options?.updateQueries ?? [];\n const invalidateQueries = options?.invalidateQueries ?? [];\n const onSuccess = options?.onSuccess;\n const onError = options?.onError;\n const args = options?.args ?? [];\n\n // Using a custom hook to manage state specific to asynchronous operations\n const {\n setIsFetched,\n setIsLoading,\n setError,\n setIsSuccess,\n setData,\n setIsInvalidated,\n setIsEnabled,\n incrementRetryCount,\n resetRetryCount,\n } = useAsyncStateStore(\n useShallow((state) => ({\n setIsFetched: state.setIsFetched,\n setIsLoading: state.setIsLoading,\n setError: state.setError,\n setIsSuccess: state.setIsSuccess,\n setIsInvalidated: state.setIsInvalidated,\n setIsEnabled: state.setIsEnabled,\n setData: state.setData,\n incrementRetryCount: state.incrementRetryCount,\n resetRetryCount: state.resetRetryCount,\n }))\n );\n\n // Storing the last arguments used to call the async function\n const storedArgsRef = useRef<any>(args ?? []);\n\n // Apply different key for different requests\n const keyWithArgs = getKeyWithArgs(key, storedArgsRef.current);\n\n // Retrieving the current state of async operations using the same custom hook\n const {\n isFetched,\n fetchedDateTime,\n isLoading,\n isEnabled: isEnabledState,\n error,\n isSuccess,\n isInvalidated,\n data,\n retryCount: errorCount,\n } = useAsyncStateStore((state) => state.getStates(keyWithArgs));\n\n const isEnabled = isEnabledState || enabled;\n const isDisabled = !isEnabled;\n\n // The core fetching function, designed to be called directly or automatically based on configuration\n const fetch: T = useCallback<T>(\n (async (...args) => {\n const keyWithArgs = getKeyWithArgs(key, args);\n\n if (pendingPromises.has(keyWithArgs)) {\n // Return the existing pending promise\n return pendingPromises.get(keyWithArgs);\n }\n\n const promise = (async () => {\n setIsLoading(keyWithArgs, true);\n let response = null;\n let errorResponse = null;\n\n await asyncFunction(...args)\n .then((result) => {\n const isResultChanged =\n JSON.stringify(result) !== JSON.stringify(data);\n\n response = result;\n if (isResultChanged) {\n setData(keyWithArgs, result);\n }\n setIsSuccess(keyWithArgs, true);\n onSuccess?.(result);\n resetRetryCount(keyWithArgs);\n\n // Store the result in session storage\n if (storeEnabled) {\n sessionStorage.setItem(keyWithArgs, JSON.stringify(result));\n }\n\n // Update other queries if necessary\n if (isResultChanged && updateQueries.length > 0) {\n updateQueries.forEach((key) => {\n setData(key, result);\n });\n }\n\n // Invalidate other queries if necessary\n if (isResultChanged && invalidateQueries.length > 0) {\n invalidateQueries.forEach((key) => {\n setIsInvalidated(key, true);\n });\n }\n })\n .catch((error) => {\n const errorMessage = error.message ?? 'An error occurred';\n\n setData(keyWithArgs, null);\n setError(keyWithArgs, errorMessage);\n incrementRetryCount(keyWithArgs);\n onError?.(errorMessage);\n errorResponse = error;\n })\n .finally(() => {\n setIsLoading(keyWithArgs, false);\n setIsFetched(keyWithArgs, true);\n setIsInvalidated(keyWithArgs, false);\n\n // Remove the pending promise from the cache\n pendingPromises.delete(keyWithArgs);\n });\n\n if (errorResponse) {\n throw new Error(errorResponse);\n }\n\n return response;\n })();\n\n // Store the pending promise in the cache\n pendingPromises.set(keyWithArgs, promise);\n }) as T,\n [asyncFunction, keyWithArgs]\n );\n\n // Wrapped execution function to handle disabled state and check for success before re-fetching\n const execute: T = useCallback<T>(\n (async (...args) => {\n if (isDisabled) return;\n if (isLoading) return;\n if (isSuccess && cacheEnabled && data) return data;\n\n if (args) {\n storedArgsRef.current = args;\n }\n\n await fetch(...args);\n }) as T,\n [isDisabled, cacheEnabled, isSuccess, data, isLoading]\n );\n\n // Function to revalidate the data when necessary\n const revalidate: T = useCallback<T>(\n (async (...args) => {\n if (isDisabled) return;\n if (isSuccess) return;\n if (isLoading) return;\n\n if (args) {\n storedArgsRef.current = args;\n }\n\n await fetch(...storedArgsRef.current);\n }) as T,\n [isDisabled, storedArgsRef, isSuccess, isLoading]\n );\n\n const autoRevalidate = useCallback(() => {\n if (isDisabled) return;\n if (isLoading || !(cacheEnabled || storeEnabled)) return;\n if (!revalidationEnabled || revalidateTime <= 0 || !isSuccess) return;\n if (!fetchedDateTime) return;\n\n const now = new Date().getTime();\n const lastFetchedTime = new Date(fetchedDateTime).getTime();\n const shouldRevalidate = now - lastFetchedTime >= revalidateTime;\n if (shouldRevalidate) {\n fetch(...storedArgsRef.current);\n }\n }, [\n cacheEnabled,\n revalidationEnabled,\n revalidateTime,\n isSuccess,\n fetchedDateTime,\n isLoading,\n isDisabled,\n ]);\n\n useEffect(() => {\n setIsEnabled(keyWithArgs, enabled);\n }, [enabled]);\n\n // Auto-fetch data on hook mount if autoFetch is true\n useEffect(() => {\n if (!autoFetch) return;\n if (isDisabled) return;\n if (isFetched || isLoading) return;\n\n fetch(...storedArgsRef.current);\n }, [autoFetch, isFetched, isDisabled, isLoading]);\n\n // Handle retry based on conditions set in options\n useEffect(() => {\n const isRetryEnabled = errorCount > 0 && retryLimit > 0;\n const isRetryLimitReached = errorCount >= retryLimit;\n if (isDisabled) return;\n if (!(cacheEnabled || storeEnabled)) return;\n if (!isRetryEnabled || isRetryLimitReached) return;\n if (isSuccess) return;\n if (isLoading) return;\n\n const timeOut = setTimeout(() => {\n if (isRetryEnabled && !isRetryLimitReached && !isSuccess) {\n execute(...storedArgsRef.current);\n }\n }, retryTime);\n\n return () => clearTimeout(timeOut);\n }, [execute, errorCount, retryLimit, retryTime, isSuccess]);\n\n // Handle periodic revalidation if caching is enabled\n useEffect(() => {\n const interval = setInterval(autoRevalidate, revalidateTime);\n\n return () => clearInterval(interval);\n }, [autoRevalidate, revalidateTime]);\n\n // Load data from session storage if storeEnabled is true\n useEffect(() => {\n if (isDisabled) return;\n if (!storeEnabled) return;\n if (isInvalidated) return;\n if (isFetched) return;\n\n const storedData = sessionStorage.getItem(keyWithArgs);\n\n if (storedData) {\n setData(keyWithArgs, JSON.parse(storedData));\n }\n }, [storeEnabled, keyWithArgs, isFetched, isInvalidated, isDisabled]);\n\n // Handle invalidation if props are changed\n useEffect(() => {\n if (!isInvalidatedProps) return;\n setIsInvalidated(keyWithArgs, isInvalidatedProps);\n }, [isInvalidatedProps]);\n\n // Memoization of the setData function to prevent unnecessary re-renders\n const setDataMemo = useCallback(\n (data: Awaited<ReturnType<T> | null>) => {\n setData(keyWithArgs, data);\n },\n [keyWithArgs]\n );\n\n // Return the hook's result, including all state and control functions\n return {\n isFetched,\n isLoading,\n isInvalidated,\n error,\n isSuccess,\n data,\n retryCount: errorCount,\n isDisabled,\n isEnabled,\n [key]: execute,\n revalidate,\n setData: setDataMemo,\n } as UseAsyncResultBase<T> & Record<U, T>;\n};\n"],"names":["ReactExports","useRef","args","keyWithArgs","key","error","data"],"mappings":";;;AAEA,SAAS,QAAQ,MAAM,MAAM;AAC3B,MAAI,OAAO,GAAG,MAAM,IAAI,GAAG;AACzB,WAAO;AAAA,EACR;AACD,MAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,OAAO,SAAS,YAAY,SAAS,MAAM;AAC1F,WAAO;AAAA,EACR;AACD,MAAI,gBAAgB,OAAO,gBAAgB,KAAK;AAC9C,QAAI,KAAK,SAAS,KAAK,KAAM,QAAO;AACpC,eAAW,CAAC,KAAK,KAAK,KAAK,MAAM;AAC/B,UAAI,CAAC,OAAO,GAAG,OAAO,KAAK,IAAI,GAAG,CAAC,GAAG;AACpC,eAAO;AAAA,MACR;AAAA,IACF;AACD,WAAO;AAAA,EACR;AACD,MAAI,gBAAgB,OAAO,gBAAgB,KAAK;AAC9C,QAAI,KAAK,SAAS,KAAK,KAAM,QAAO;AACpC,eAAW,SAAS,MAAM;AACxB,UAAI,CAAC,KAAK,IAAI,KAAK,GAAG;AACpB,eAAO;AAAA,MACR;AAAA,IACF;AACD,WAAO;AAAA,EACR;AACD,QAAM,QAAQ,OAAO,KAAK,IAAI;AAC9B,MAAI,MAAM,WAAW,OAAO,KAAK,IAAI,EAAE,QAAQ;AAC7C,WAAO;AAAA,EACR;AACD,aAAW,QAAQ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OAAO;AAAA,EAAA,GAChC,CAAC,SAAS,YAAY,YAAY,WAAW,SAAS,CAAC;AAG1D,YAAU,MAAM;AACR,UAAA,WAAW,YAAY,gBAAgB,cAAc;AAEpD,WAAA,MAAM,cAAc,QAAQ;AAAA,EAAA,GAClC,CAAC,gBAAgB,cAAc,CAAC;AAGnC,YAAU,MAAM;AACd,QAAI,WAAY;AAChB,QAAI,CAAC,aAAc;AACnB,QAAI,cAAe;AACnB,QAAI,UAAW;AAET,UAAA,aAAa,eAAe,QAAQ,WAAW;AAErD,QAAI,YAAY;AACd,cAAQ,aAAa,KAAK,MAAM,UAAU,CAAC;AAAA,IAC7C;AAAA,EAAA,GACC,CAAC,cAAc,aAAa,WAAW,eAAe,UAAU,CAAC;AAGpE,YAAU,MAAM;AACd,QAAI,CAAC,mBAAoB;AACzB,qBAAiB,aAAa,kBAAkB;AAAA,EAAA,GAC/C,CAAC,kBAAkB,CAAC;AAGvB,QAAM,cAAc;AAAA,IAClB,CAACI,UAAwC;AACvC,cAAQ,aAAaA,KAAI;AAAA,IAC3B;AAAA,IACA,CAAC,WAAW;AAAA,EAAA;AAIP,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA,CAAC,GAAG,GAAG;AAAA,IACP;AAAA,IACA,SAAS;AAAA,EAAA;AAEb;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"useAsync.mjs","sources":["../../../../../../node_modules/.pnpm/zustand@4.5.5_@types+react@18.3.12_react@18.3.1/node_modules/zustand/esm/react/shallow.mjs","../../../src/hooks/useAsync/useAsync.ts"],"sourcesContent":["import ReactExports from 'react';\n\nfunction shallow(objA, objB) {\n if (Object.is(objA, objB)) {\n return true;\n }\n if (typeof objA !== \"object\" || objA === null || typeof objB !== \"object\" || objB === null) {\n return false;\n }\n if (objA instanceof Map && objB instanceof Map) {\n if (objA.size !== objB.size) return false;\n for (const [key, value] of objA) {\n if (!Object.is(value, objB.get(key))) {\n return false;\n }\n }\n return true;\n }\n if (objA instanceof Set && objB instanceof Set) {\n if (objA.size !== objB.size) return false;\n for (const value of objA) {\n if (!objB.has(value)) {\n return false;\n }\n }\n return true;\n }\n const keysA = Object.keys(objA);\n if (keysA.length !== Object.keys(objB).length) {\n return false;\n }\n for (const keyA of keysA) {\n if (!Object.prototype.hasOwnProperty.call(objB, keyA) || !Object.is(objA[keyA], objB[keyA])) {\n return false;\n }\n }\n return true;\n}\n\nconst { useRef } = ReactExports;\nfunction useShallow(selector) {\n const prev = useRef();\n return (state) => {\n const next = selector(state);\n return shallow(prev.current, next) ? prev.current : prev.current = next;\n };\n}\n\nexport { useShallow };\n","'use client';\n\n// This is an ESLint directive to disable specific rules.\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { useCallback, useEffect, useRef } from 'react';\nimport { useShallow } from 'zustand/react/shallow';\nimport { useAsyncStateStore } from './useAsyncStateStore';\n\n// Pending promises cache to prevent parallel requests when multiple components use the hook\nconst pendingPromises = new Map();\n\n// Defines the base structure for the result of the custom hook.\ntype UseAsyncResultBase<T extends (...args: any[]) => Promise<any>> = {\n isFetched: boolean;\n isLoading: boolean;\n isInvalidated: boolean;\n isSuccess: boolean;\n isDisabled: boolean;\n error: string | null;\n data: Awaited<ReturnType<T>> | null;\n retryCount: number;\n revalidate: T;\n setData: (data: Awaited<ReturnType<T> | null>) => void;\n};\n\n// Options type for the hook, allowing customization of behavior.\nexport type UseAsyncOptions<T extends (...args: any[]) => Promise<any>> = {\n retryLimit?: number; // The number of times the hook should retry the function on failure before giving up\n retryTime?: number; // Time in milliseconds for retrying the data\n cache?: boolean; // Cache the result of the function using zustand\n store?: boolean; // Store the result of the function in session storage\n enable?: boolean; // Enable the hook\n autoFetch?: boolean; // Automatically fetch the data when the hook is mounted\n revalidation?: boolean; // Enable revalidation\n revalidateTime?: number; // Time in milliseconds for revalidating the data\n isInvalidated?: boolean; // Determine if the data is invalidated and should be refetched\n invalidateQueries?: string[]; // Invalidate other queries when the data is updated\n updateQueries?: string[]; // Update other queries when the data is updated\n onSuccess?: (data: Awaited<ReturnType<T>>) => void; // Callback function that is called when the asynchronous function resolves successfully\n onError?: (error: string) => void; // Callback function that is called when the asynchronous function rejects or encounters an error\n args?: Parameters<T>; // Arguments to pass to the asynchronous function\n};\n\n// Default values for the hook's options\nconst DEFAULT_CACHE_ENABLED = false;\nconst DEFAULT_STORE_ENABLED = false;\nconst DEFAULT_ENABLED = true;\nconst DEFAULT_AUTO_FETCH = false;\nconst DEFAULT_RETRY_LIMIT = 1;\nconst DEFAULT_REVALIDATION_ENABLED = false;\nconst DEFAULT_REVALIDATE_TIME = 5 * 60 * 1000; // 5 minutes\nconst DEFAULT_RETRY_TIME = 5 * 60 * 1000; // 5 minutes\n\n// The main hook type that includes the async function along with its additional properties.\nexport type UseAsyncResult<\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n> = UseAsyncResultBase<T> & Record<U, T>;\n\nconst getKeyWithArgs = (key: string, args: any[]) =>\n args.length > 0 ? `${key}/${JSON.stringify(args)}` : key;\n\n/**\n * A custom React hook that manages asynchronous operations, providing easy-to-use states and controls over fetching, caching, and retry mechanisms.\n * This hook abstracts away the complexity of handling loading, error, and success states for any asynchronous function.\n *\n * @template U - A string type that extends the keys of the async function, used as a key to store and retrieve state.\n * @template T - A function type that must return a Promise, representing the asynchronous operation to be managed.\n *\n * @param {U} key - A unique identifier for the async operation, used to handle state internally and avoid conflicts.\n * @param {T} asyncFunction - The asynchronous function that will be managed by this hook. This function should return a Promise.\n * @param {UseAsyncOptions<T>} [options] - Optional configuration options to customize the behavior of the hook.\n * @returns {UseAsyncResult<U, T>} The states and controls related to the managed async function. Includes states like isLoading, isSuccess, and provides control methods like revalidate and setData.\n *\n * @typedef {Object} UseAsyncOptions\n * @property {number} [retryTime=300000] - Time in milliseconds for retrying the data after an error occurs.\n * @property {number} [retryLimit=1] - The number of times the hook should retry the asynchronous function on failure before giving up.\n * @property {boolean} [revalidation=false] - Enable revalidation.\n * @property {number} [revalidateTime=300000] - Time in milliseconds after which the cached data is considered stale and the async function is re-invoked, if caching is enabled.\n * @property {boolean} [cache=false] - Whether to cache the result of the async function. When enabled, revalidation is controlled by `revalidateTime`.\n * @property {boolean} [store=false] - Store the result of the function in session storage.\n * @property {boolean} [autoFetch=false] - Whether the hook should automatically invoke the asynchronous function on mount.\n * @property {number} [revalidateTime=300000] - Time in milliseconds after which the cached data is considered stale and the async function is re-invoked, if caching is enabled.\n * @property {boolean} [isInvalidated=false] - Determine if the data is invalidated and should be refetched.\n * @property {string[]} [updateQueries=[]] - Update other queries when the data is updated.\n * @property {string[]} [invalidateQueries=[]] - Invalidate other queries when the data is updated.\n * @property {(data: Awaited<ReturnType<T>>) => void} [onSuccess] - Callback function that is called when the asynchronous function resolves successfully.\n * @property {(error: string) => void} [onError] - Callback function that is called when the asynchronous function rejects or encounters an error.\n * @property {Parameters<T>} [args=[]] - Arguments to pass to the asynchronous function.\n *\n *\n * @example\n * // Example of using useAsync to manage fetching user data from an API.\n * const fetchUserData = async (userId) => {\n * const response = await fetch(`/api/users/${userId}`);\n * if (!response.ok) throw new Error('Failed to fetch');\n * return await response.json();\n * };\n *\n * const UserDetails = ({ userId }) => {\n * const {\n * isLoading,\n * data,\n * error,\n * revalidate,\n * } = useAsync('userDetails', fetchUserData, {\n * cache: true,\n * revalidateTime: 60000, // 1 minute\n * autoFetch: true,\n * onSuccess: (data) => console.log('User data fetched successfully:', data),\n * onError: (error) => console.error('Error fetching user data:', error),\n * });\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error}</div>;\n * return (\n * <div>\n * <h1>{data.name}</h1>\n * <button onClick={() => revalidate()}>Refresh</button>\n * </div>\n * );\n * };\n */\nexport const useAsync = <\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n>(\n key: U,\n asyncFunction: T,\n options?: UseAsyncOptions<T>\n): UseAsyncResult<U, T> => {\n // Resolving optional parameters with default values\n const retryLimit = options?.retryLimit ?? DEFAULT_RETRY_LIMIT;\n const autoFetch = options?.autoFetch ?? DEFAULT_AUTO_FETCH;\n const retryTime = options?.retryTime ?? DEFAULT_RETRY_TIME;\n const cacheEnabled = options?.cache ?? DEFAULT_CACHE_ENABLED;\n const storeEnabled = options?.store ?? DEFAULT_STORE_ENABLED;\n const enabled = options?.enable ?? DEFAULT_ENABLED;\n const revalidationEnabled =\n options?.revalidation ?? DEFAULT_REVALIDATION_ENABLED;\n const revalidateTime = options?.revalidateTime ?? DEFAULT_REVALIDATE_TIME;\n const isInvalidatedProps = options?.isInvalidated ?? false;\n const updateQueries = options?.updateQueries ?? [];\n const invalidateQueries = options?.invalidateQueries ?? [];\n const onSuccess = options?.onSuccess;\n const onError = options?.onError;\n const args = options?.args ?? [];\n\n // Using a custom hook to manage state specific to asynchronous operations\n const {\n setIsFetched,\n setIsLoading,\n setError,\n setIsSuccess,\n setData,\n setIsInvalidated,\n setIsEnabled,\n incrementRetryCount,\n resetRetryCount,\n } = useAsyncStateStore(\n useShallow((state) => ({\n setIsFetched: state.setIsFetched,\n setIsLoading: state.setIsLoading,\n setError: state.setError,\n setIsSuccess: state.setIsSuccess,\n setIsInvalidated: state.setIsInvalidated,\n setIsEnabled: state.setIsEnabled,\n setData: state.setData,\n incrementRetryCount: state.incrementRetryCount,\n resetRetryCount: state.resetRetryCount,\n }))\n );\n\n // Storing the last arguments used to call the async function\n const storedArgsRef = useRef<any>(args ?? []);\n\n // Apply different key for different requests\n const keyWithArgs = getKeyWithArgs(key, storedArgsRef.current);\n\n // Retrieving the current state of async operations using the same custom hook\n const {\n isFetched,\n fetchedDateTime,\n isLoading,\n isEnabled: isEnabledState,\n error,\n isSuccess,\n isInvalidated,\n data,\n retryCount: errorCount,\n } = useAsyncStateStore((state) => state.getStates(keyWithArgs));\n\n const isEnabled = isEnabledState || enabled;\n const isDisabled = !isEnabled;\n\n // The core fetching function, designed to be called directly or automatically based on configuration\n const fetch: T = useCallback<T>(\n (async (...args) => {\n const keyWithArgs = getKeyWithArgs(key, args);\n\n if (pendingPromises.has(keyWithArgs)) {\n // Return the existing pending promise\n return pendingPromises.get(keyWithArgs);\n }\n\n const promise = (async () => {\n setIsLoading(keyWithArgs, true);\n let response = null;\n let errorResponse = null;\n\n await asyncFunction(...args)\n .then((result) => {\n const isResultChanged =\n JSON.stringify(result) !== JSON.stringify(data);\n\n response = result;\n if (isResultChanged) {\n setData(keyWithArgs, result);\n }\n setIsSuccess(keyWithArgs, true);\n onSuccess?.(result);\n resetRetryCount(keyWithArgs);\n\n // Store the result in session storage\n if (storeEnabled) {\n sessionStorage.setItem(keyWithArgs, JSON.stringify(result));\n }\n\n // Update other queries if necessary\n if (isResultChanged && updateQueries.length > 0) {\n updateQueries.forEach((key) => {\n setData(key, result);\n });\n }\n\n // Invalidate other queries if necessary\n if (isResultChanged && invalidateQueries.length > 0) {\n invalidateQueries.forEach((key) => {\n setIsInvalidated(key, true);\n });\n }\n })\n .catch((error) => {\n const errorMessage = error.message ?? 'An error occurred';\n console.error(JSON.stringify(error));\n\n setData(keyWithArgs, null);\n setError(keyWithArgs, errorMessage);\n incrementRetryCount(keyWithArgs);\n onError?.(errorMessage);\n errorResponse = error;\n })\n .finally(() => {\n setIsLoading(keyWithArgs, false);\n setIsFetched(keyWithArgs, true);\n setIsInvalidated(keyWithArgs, false);\n\n // Remove the pending promise from the cache\n pendingPromises.delete(keyWithArgs);\n });\n\n return response;\n })();\n\n // Store the pending promise in the cache\n pendingPromises.set(keyWithArgs, promise);\n }) as T,\n [asyncFunction, keyWithArgs]\n );\n\n // Wrapped execution function to handle disabled state and check for success before re-fetching\n const execute: T = useCallback<T>(\n (async (...args) => {\n if (isDisabled) return;\n if (isLoading) return;\n if (isSuccess && cacheEnabled && data) return data;\n\n if (args) {\n storedArgsRef.current = args;\n }\n\n await fetch(...args);\n }) as T,\n [isDisabled, cacheEnabled, isSuccess, data, isLoading]\n );\n\n // Function to revalidate the data when necessary\n const revalidate: T = useCallback<T>(\n (async (...args) => {\n if (isDisabled) return;\n if (isSuccess) return;\n if (isLoading) return;\n\n if (args) {\n storedArgsRef.current = args;\n }\n\n await fetch(...storedArgsRef.current);\n }) as T,\n [isDisabled, storedArgsRef, isSuccess, isLoading]\n );\n\n const autoRevalidate = useCallback(() => {\n if (isDisabled) return;\n if (isLoading || !(cacheEnabled || storeEnabled)) return;\n if (!revalidationEnabled || revalidateTime <= 0 || !isSuccess) return;\n if (!fetchedDateTime) return;\n\n const now = new Date().getTime();\n const lastFetchedTime = new Date(fetchedDateTime).getTime();\n const shouldRevalidate = now - lastFetchedTime >= revalidateTime;\n if (shouldRevalidate) {\n fetch(...storedArgsRef.current);\n }\n }, [\n cacheEnabled,\n revalidationEnabled,\n revalidateTime,\n isSuccess,\n fetchedDateTime,\n isLoading,\n isDisabled,\n ]);\n\n useEffect(() => {\n setIsEnabled(keyWithArgs, enabled);\n }, [enabled]);\n\n // Auto-fetch data on hook mount if autoFetch is true\n useEffect(() => {\n if (!autoFetch) return;\n if (isDisabled) return;\n if (isFetched || isLoading) return;\n\n fetch(...storedArgsRef.current);\n }, [autoFetch, isFetched, isDisabled, isLoading]);\n\n // Handle retry based on conditions set in options\n useEffect(() => {\n const isRetryEnabled = errorCount > 0 && retryLimit > 0;\n const isRetryLimitReached = errorCount >= retryLimit;\n if (isDisabled) return;\n if (!(cacheEnabled || storeEnabled)) return;\n if (!isRetryEnabled || isRetryLimitReached) return;\n if (isSuccess) return;\n if (isLoading) return;\n\n const timeOut = setTimeout(() => {\n if (isRetryEnabled && !isRetryLimitReached && !isSuccess) {\n execute(...storedArgsRef.current);\n }\n }, retryTime);\n\n return () => clearTimeout(timeOut);\n }, [execute, errorCount, retryLimit, retryTime, isSuccess]);\n\n // Handle periodic revalidation if caching is enabled\n useEffect(() => {\n const interval = setInterval(autoRevalidate, revalidateTime);\n\n return () => clearInterval(interval);\n }, [autoRevalidate, revalidateTime]);\n\n // Load data from session storage if storeEnabled is true\n useEffect(() => {\n if (isDisabled) return;\n if (!storeEnabled) return;\n if (isInvalidated) return;\n if (isFetched) return;\n\n const storedData = sessionStorage.getItem(keyWithArgs);\n\n if (storedData) {\n setData(keyWithArgs, JSON.parse(storedData));\n }\n }, [storeEnabled, keyWithArgs, isFetched, isInvalidated, isDisabled]);\n\n // Handle invalidation if props are changed\n useEffect(() => {\n if (!isInvalidatedProps) return;\n setIsInvalidated(keyWithArgs, isInvalidatedProps);\n }, [isInvalidatedProps]);\n\n // Memoization of the setData function to prevent unnecessary re-renders\n const setDataMemo = useCallback(\n (data: Awaited<ReturnType<T> | null>) => {\n setData(keyWithArgs, data);\n },\n [keyWithArgs]\n );\n\n // Return the hook's result, including all state and control functions\n return {\n isFetched,\n isLoading,\n isInvalidated,\n error,\n isSuccess,\n data,\n retryCount: errorCount,\n isDisabled,\n isEnabled,\n [key]: execute,\n revalidate,\n setData: setDataMemo,\n } as UseAsyncResultBase<T> & Record<U, T>;\n};\n"],"names":["ReactExports","useRef","args","keyWithArgs","key","error","data"],"mappings":";;;AAEA,SAAS,QAAQ,MAAM,MAAM;AAC3B,MAAI,OAAO,GAAG,MAAM,IAAI,GAAG;AACzB,WAAO;AAAA,EACR;AACD,MAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,OAAO,SAAS,YAAY,SAAS,MAAM;AAC1F,WAAO;AAAA,EACR;AACD,MAAI,gBAAgB,OAAO,gBAAgB,KAAK;AAC9C,QAAI,KAAK,SAAS,KAAK,KAAM,QAAO;AACpC,eAAW,CAAC,KAAK,KAAK,KAAK,MAAM;AAC/B,UAAI,CAAC,OAAO,GAAG,OAAO,KAAK,IAAI,GAAG,CAAC,GAAG;AACpC,eAAO;AAAA,MACR;AAAA,IACF;AACD,WAAO;AAAA,EACR;AACD,MAAI,gBAAgB,OAAO,gBAAgB,KAAK;AAC9C,QAAI,KAAK,SAAS,KAAK,KAAM,QAAO;AACpC,eAAW,SAAS,MAAM;AACxB,UAAI,C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AW;AAET,UAAA,UAAU,WAAW,MAAM;AAC/B,UAAI,kBAAkB,CAAC,uBAAuB,CAAC,WAAW;AAChD,gBAAA,GAAG,cAAc,OAAO;AAAA,MAClC;AAAA,OACC,SAAS;AAEL,WAAA,MAAM,aAAa,OAAO;AAAA,EAAA,GAChC,CAAC,SAAS,YAAY,YAAY,WAAW,SAAS,CAAC;AAG1D,YAAU,MAAM;AACR,UAAA,WAAW,YAAY,gBAAgB,cAAc;AAEpD,WAAA,MAAM,cAAc,QAAQ;AAAA,EAAA,GAClC,CAAC,gBAAgB,cAAc,CAAC;AAGnC,YAAU,MAAM;AACd,QAAI,WAAY;AAChB,QAAI,CAAC,aAAc;AACnB,QAAI,cAAe;AACnB,QAAI,UAAW;AAET,UAAA,aAAa,eAAe,QAAQ,WAAW;AAErD,QAAI,YAAY;AACd,cAAQ,aAAa,KAAK,MAAM,UAAU,CAAC;AAAA,IAC7C;AAAA,EAAA,GACC,CAAC,cAAc,aAAa,WAAW,eAAe,UAAU,CAAC;AAGpE,YAAU,MAAM;AACd,QAAI,CAAC,mBAAoB;AACzB,qBAAiB,aAAa,kBAAkB;AAAA,EAAA,GAC/C,CAAC,kBAAkB,CAAC;AAGvB,QAAM,cAAc;AAAA,IAClB,CAACI,UAAwC;AACvC,cAAQ,aAAaA,KAAI;AAAA,IAC3B;AAAA,IACA,CAAC,WAAW;AAAA,EAAA;AAIP,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA,CAAC,GAAG,GAAG;AAAA,IACP;AAAA,IACA,SAAS;AAAA,EAAA;AAEb;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
const jsxRuntime = require("./jsx-runtime-DvCoRj5u.cjs");
|
|
4
|
+
const core = require("@intlayer/core");
|
|
5
|
+
const require$$0 = require("react");
|
|
6
|
+
const lucideReact = require("lucide-react");
|
|
7
|
+
const components_DictionaryEditor_ItemLayout = require("./components/DictionaryEditor/ItemLayout.cjs");
|
|
8
|
+
const components_DictionaryEditor_NodeWrapper_StringWrapper = require("./components/DictionaryEditor/NodeWrapper/StringWrapper.cjs");
|
|
9
|
+
const components_DictionaryEditor_useEditedContentStore = require("./components/DictionaryEditor/useEditedContentStore.cjs");
|
|
10
|
+
const ArrayWrapper = (props) => {
|
|
11
|
+
const {
|
|
12
|
+
keyPath,
|
|
13
|
+
section,
|
|
14
|
+
onFocusKeyPath,
|
|
15
|
+
onClickEdit,
|
|
16
|
+
focusedKeyPath = []
|
|
17
|
+
} = props;
|
|
18
|
+
return section.map((subSection, key) => {
|
|
19
|
+
const newKeyPathEl = {
|
|
20
|
+
key,
|
|
21
|
+
type: core.NodeType.Array
|
|
22
|
+
};
|
|
23
|
+
const newKeyPath = [...keyPath, newKeyPathEl];
|
|
24
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
|
|
25
|
+
components_DictionaryEditor_ItemLayout.ItemLayout,
|
|
26
|
+
{
|
|
27
|
+
level: keyPath.length,
|
|
28
|
+
title: `${key}`,
|
|
29
|
+
description: "",
|
|
30
|
+
isSelected: core.isSameKeyPath(newKeyPath, focusedKeyPath),
|
|
31
|
+
onClick: (e) => {
|
|
32
|
+
e.stopPropagation();
|
|
33
|
+
onFocusKeyPath(newKeyPath);
|
|
34
|
+
},
|
|
35
|
+
rightParam: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
|
|
36
|
+
lucideReact.Edit,
|
|
37
|
+
{
|
|
38
|
+
size: 16,
|
|
39
|
+
role: "button",
|
|
40
|
+
"aria-label": "Open the editor",
|
|
41
|
+
onClick: (e) => {
|
|
42
|
+
e.stopPropagation();
|
|
43
|
+
onClickEdit?.(newKeyPath);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
),
|
|
47
|
+
children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(NodeWrapper, { ...props, keyPath: newKeyPath, section: subSection })
|
|
48
|
+
},
|
|
49
|
+
JSON.stringify(subSection)
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
const EnumerationWrapper = (props) => {
|
|
54
|
+
const { keyPath, section } = props;
|
|
55
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("div", { className: "ml-2 grid grid-cols-[auto,1fr] gap-2", children: Object.keys(section).filter((key) => !traceKeys.includes(key)).map((key) => {
|
|
56
|
+
const newKeyPathEl = {
|
|
57
|
+
type: core.NodeType.Enumeration,
|
|
58
|
+
key
|
|
59
|
+
};
|
|
60
|
+
const newKeyPath = [...keyPath, newKeyPathEl];
|
|
61
|
+
const subSection = section.enumeration[key];
|
|
62
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment, { children: [
|
|
63
|
+
/* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("span", { className: "flex items-center font-bold", children: key }),
|
|
64
|
+
/* @__PURE__ */ require$$0.createElement(
|
|
65
|
+
NodeWrapper,
|
|
66
|
+
{
|
|
67
|
+
...props,
|
|
68
|
+
key,
|
|
69
|
+
keyPath: newKeyPath,
|
|
70
|
+
section: subSection
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
] });
|
|
74
|
+
}) });
|
|
75
|
+
};
|
|
76
|
+
const NestedObjectWrapper = (props) => {
|
|
77
|
+
const {
|
|
78
|
+
keyPath,
|
|
79
|
+
section,
|
|
80
|
+
focusedKeyPath = [],
|
|
81
|
+
onClickEdit,
|
|
82
|
+
onFocusKeyPath
|
|
83
|
+
} = props;
|
|
84
|
+
return Object.keys(section).filter((key) => !traceKeys.includes(key)).map((key) => {
|
|
85
|
+
const newKeyPathEl = { key, type: core.NodeType.Object };
|
|
86
|
+
const newKeyPath = [...keyPath, newKeyPathEl];
|
|
87
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
|
|
88
|
+
components_DictionaryEditor_ItemLayout.ItemLayout,
|
|
89
|
+
{
|
|
90
|
+
level: keyPath.length,
|
|
91
|
+
title: key,
|
|
92
|
+
description: "",
|
|
93
|
+
isSelected: core.isSameKeyPath(newKeyPath, focusedKeyPath),
|
|
94
|
+
onClick: (e) => {
|
|
95
|
+
e.stopPropagation();
|
|
96
|
+
onFocusKeyPath(newKeyPath);
|
|
97
|
+
},
|
|
98
|
+
rightParam: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
|
|
99
|
+
lucideReact.Edit,
|
|
100
|
+
{
|
|
101
|
+
size: 16,
|
|
102
|
+
role: "button",
|
|
103
|
+
"aria-label": "Open the editor",
|
|
104
|
+
onClick: (e) => {
|
|
105
|
+
e.stopPropagation();
|
|
106
|
+
onClickEdit?.(newKeyPath);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
),
|
|
110
|
+
children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(NodeWrapper, { ...props, keyPath: newKeyPath, section: section[key] })
|
|
111
|
+
},
|
|
112
|
+
key
|
|
113
|
+
);
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
const TranslationWrapper = (props) => {
|
|
117
|
+
const { keyPath, section, locale } = props;
|
|
118
|
+
const newKeyPathEl = {
|
|
119
|
+
type: core.NodeType.Translation,
|
|
120
|
+
key: locale
|
|
121
|
+
};
|
|
122
|
+
const newKeyPath = [...keyPath, newKeyPathEl];
|
|
123
|
+
const subSection = section.translation[locale];
|
|
124
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(NodeWrapper, { ...props, keyPath: newKeyPath, section: subSection });
|
|
125
|
+
};
|
|
126
|
+
const traceKeys = ["filePath", "id", "nodeType"];
|
|
127
|
+
const isReactNode = (node) => typeof node?.key !== "undefined" && typeof node?.props !== "undefined";
|
|
128
|
+
const createReactElement = (element) => {
|
|
129
|
+
if (typeof element === "string") {
|
|
130
|
+
return element;
|
|
131
|
+
}
|
|
132
|
+
const convertChildrenAsArray = (element2) => {
|
|
133
|
+
if (element2?.props && typeof element2.props.children === "object") {
|
|
134
|
+
const childrenResult = [];
|
|
135
|
+
const { children } = element2.props;
|
|
136
|
+
Object.keys(children).forEach((key) => {
|
|
137
|
+
childrenResult.push(createReactElement(children[key]));
|
|
138
|
+
});
|
|
139
|
+
return {
|
|
140
|
+
...element2,
|
|
141
|
+
props: { ...element2.props, children: childrenResult }
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
...element2,
|
|
146
|
+
props: { ...element2.props, children: element2.props.children }
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
const fixedElement = convertChildrenAsArray(element);
|
|
150
|
+
const { type, props } = fixedElement;
|
|
151
|
+
return require$$0.createElement(type ?? "div", props, ...props.children);
|
|
152
|
+
};
|
|
153
|
+
const NodeWrapper = (props) => {
|
|
154
|
+
const { section } = props;
|
|
155
|
+
components_DictionaryEditor_useEditedContentStore.useEditedContentStore((s) => ({
|
|
156
|
+
addEditedContent: s.addEditedContent
|
|
157
|
+
}));
|
|
158
|
+
if (typeof section === "object") {
|
|
159
|
+
if (isReactNode(section)) {
|
|
160
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment, { children: [
|
|
161
|
+
createReactElement(section),
|
|
162
|
+
/* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("span", { className: "text-neutral dark:text-neutral-dark text-xs", children: "React node not editable" })
|
|
163
|
+
] });
|
|
164
|
+
}
|
|
165
|
+
if (section.nodeType === core.NodeType.Translation) {
|
|
166
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
|
|
167
|
+
TranslationWrapper,
|
|
168
|
+
{
|
|
169
|
+
...props,
|
|
170
|
+
section
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
if (section.nodeType === core.NodeType.Enumeration) {
|
|
175
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
|
|
176
|
+
EnumerationWrapper,
|
|
177
|
+
{
|
|
178
|
+
...props,
|
|
179
|
+
section
|
|
180
|
+
}
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
if (Array.isArray(section)) {
|
|
184
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(ArrayWrapper, { ...props, section });
|
|
185
|
+
}
|
|
186
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
|
|
187
|
+
NestedObjectWrapper,
|
|
188
|
+
{
|
|
189
|
+
...props,
|
|
190
|
+
section
|
|
191
|
+
}
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
if (typeof section === "string") {
|
|
195
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(components_DictionaryEditor_NodeWrapper_StringWrapper.StringWrapper, { ...props, section });
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
exports.ArrayWrapper = ArrayWrapper;
|
|
199
|
+
exports.EnumerationWrapper = EnumerationWrapper;
|
|
200
|
+
exports.NestedObjectWrapper = NestedObjectWrapper;
|
|
201
|
+
exports.NodeWrapper = NodeWrapper;
|
|
202
|
+
exports.TranslationWrapper = TranslationWrapper;
|
|
203
|
+
exports.traceKeys = traceKeys;
|
|
204
|
+
//# sourceMappingURL=index-BUDsCMdX.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BUDsCMdX.cjs","sources":["../src/components/DictionaryEditor/NodeWrapper/ArrayWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/TranslationWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/index.tsx"],"sourcesContent":["/* eslint-disable import/no-cycle */\nimport {\n isSameKeyPath,\n NodeType,\n type DictionaryValue,\n type KeyPath,\n} from '@intlayer/core';\nimport { Edit } from 'lucide-react';\nimport type { FC } from 'react';\nimport { ItemLayout } from '../ItemLayout';\nimport { NodeWrapper, type NodeWrapperProps } from './index';\n\ntype ArrayWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: DictionaryValue[];\n};\n\nexport const ArrayWrapper: FC<ArrayWrapperProps> = (props) => {\n const {\n keyPath,\n section,\n onFocusKeyPath,\n onClickEdit,\n focusedKeyPath = [],\n } = props;\n\n return section.map((subSection, key) => {\n const newKeyPathEl: KeyPath = {\n key,\n type: NodeType.Array,\n };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n return (\n <ItemLayout\n level={keyPath.length}\n key={JSON.stringify(subSection)}\n title={`${key}`}\n description=\"\"\n isSelected={isSameKeyPath(newKeyPath, focusedKeyPath)}\n onClick={(e) => {\n e.stopPropagation();\n onFocusKeyPath(newKeyPath);\n }}\n rightParam={\n <Edit\n size={16}\n role=\"button\"\n aria-label=\"Open the editor\"\n onClick={(e) => {\n e.stopPropagation();\n\n onClickEdit?.(newKeyPath);\n }}\n />\n }\n >\n <NodeWrapper {...props} keyPath={newKeyPath} section={subSection} />\n </ItemLayout>\n );\n });\n};\n","/* eslint-disable import/no-cycle */\nimport {\n type KeyPath,\n NodeType,\n type EnumerationContent,\n type DictionaryValue,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { NodeWrapper, traceKeys, type NodeWrapperProps } from './index';\n\ntype EnumerationWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: EnumerationContent<DictionaryValue>;\n};\n\nexport const EnumerationWrapper: FC<EnumerationWrapperProps> = (props) => {\n const { keyPath, section } = props;\n\n return (\n <div className=\"ml-2 grid grid-cols-[auto,1fr] gap-2\">\n {Object.keys(section)\n .filter((key) => !traceKeys.includes(key))\n .map((key) => {\n const newKeyPathEl: KeyPath = {\n type: NodeType.Enumeration,\n key,\n };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n const subSection =\n section.enumeration[key as keyof (typeof section)['enumeration']]!;\n\n return (\n <>\n <span className=\"flex items-center font-bold\">{key}</span>\n <NodeWrapper\n {...props}\n key={key}\n keyPath={newKeyPath}\n section={subSection}\n />\n </>\n );\n })}\n </div>\n );\n};\n","/* eslint-disable import/no-cycle */\n\nimport {\n type KeyPath,\n isSameKeyPath,\n type DictionaryValue,\n NodeType,\n} from '@intlayer/core';\nimport { Edit } from 'lucide-react';\nimport type { FC } from 'react';\nimport { ItemLayout } from '../ItemLayout';\nimport { NodeWrapper, traceKeys, type NodeWrapperProps } from './index';\n\ntype NestedObjectWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: Record<string, DictionaryValue>;\n};\n\nexport const NestedObjectWrapper: FC<NestedObjectWrapperProps> = (props) => {\n const {\n keyPath,\n section,\n focusedKeyPath = [],\n onClickEdit,\n onFocusKeyPath,\n } = props;\n\n return Object.keys(section)\n .filter((key) => !traceKeys.includes(key))\n .map((key) => {\n const newKeyPathEl: KeyPath = { key, type: NodeType.Object };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n return (\n <ItemLayout\n level={keyPath.length}\n key={key}\n title={key}\n description=\"\"\n isSelected={isSameKeyPath(newKeyPath, focusedKeyPath)}\n onClick={(e) => {\n e.stopPropagation();\n\n onFocusKeyPath(newKeyPath);\n }}\n rightParam={\n <Edit\n size={16}\n role=\"button\"\n aria-label=\"Open the editor\"\n onClick={(e) => {\n e.stopPropagation();\n\n onClickEdit?.(newKeyPath);\n }}\n />\n }\n >\n <NodeWrapper {...props} keyPath={newKeyPath} section={section[key]} />\n </ItemLayout>\n );\n });\n};\n","/* eslint-disable import/no-cycle */\n\nimport {\n type KeyPath,\n NodeType,\n type TranslationContent,\n type DictionaryValue,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { NodeWrapper, type NodeWrapperProps } from './index';\n\ntype TranslationWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: TranslationContent<DictionaryValue>;\n};\n\nexport const TranslationWrapper: FC<TranslationWrapperProps> = (props) => {\n const { keyPath, section, locale } = props;\n\n const newKeyPathEl: KeyPath = {\n type: NodeType.Translation,\n key: locale,\n };\n\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n const subSection =\n section.translation[\n locale as unknown as keyof (typeof section)['translation']\n ]!;\n\n return <NodeWrapper {...props} keyPath={newKeyPath} section={subSection} />;\n};\n","/* eslint-disable import/no-cycle */\n'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport {\n type EnumerationContent,\n type TranslationContent,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n type Dictionary,\n} from '@intlayer/core';\nimport {\n createElement,\n type ReactElement,\n type ReactNode,\n type FC,\n} from 'react';\nimport { ArrayWrapper } from './ArrayWrapper';\nimport { EnumerationWrapper } from './EnumerationWrapper';\nimport { NestedObjectWrapper } from './NestedObjectWrapper';\nimport { StringWrapper } from './StringWrapper';\nimport { TranslationWrapper } from './TranslationWrapper';\nimport { useEditedContentStore } from '../useEditedContentStore';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nconst isReactNode = (node: Record<string, unknown>): boolean =>\n typeof node?.key !== 'undefined' && typeof node?.props !== 'undefined';\n\nexport type NodeWrapperProps = {\n keyPath: KeyPath[];\n section: DictionaryValue;\n onContentChange: (content: { keyPath: KeyPath[]; newValue: string }) => void;\n locale: Locales;\n editedContent: Dictionary;\n focusedKeyPath: KeyPath[] | undefined;\n onFocusKeyPath: (keyPath: KeyPath[]) => void;\n onClickEdit?: (keyPath: KeyPath[]) => void;\n};\n\nconst createReactElement = (element: ReactElement) => {\n if (typeof element === 'string') {\n // If it's a string, simply return it (used for text content)\n return element;\n }\n\n const convertChildrenAsArray = (element: ReactElement): ReactElement => {\n if (element?.props && typeof element.props.children === 'object') {\n const childrenResult: ReactNode[] = [];\n const { children } = element.props;\n\n // Create the children elements recursively, if any\n Object.keys(children).forEach((key) => {\n childrenResult.push(createReactElement(children[key]));\n });\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: element.props.children },\n };\n };\n\n const fixedElement = convertChildrenAsArray(element);\n\n const { type, props } = fixedElement;\n\n // Create and return the React element\n return createElement(type ?? 'div', props, ...props.children);\n};\n\nexport const NodeWrapper: FC<NodeWrapperProps> = (props) => {\n const { section } = props;\n\n const { addEditedContent } = useEditedContentStore((s) => ({\n addEditedContent: s.addEditedContent,\n }));\n\n if (typeof section === 'object') {\n if (isReactNode(section as Record<string, unknown>)) {\n return (\n <>\n {createReactElement(section as unknown as ReactElement)}\n <span className=\"text-neutral dark:text-neutral-dark text-xs\">\n React node not editable\n </span>\n </>\n );\n }\n\n if (\n (section as TranslationContent<DictionaryValue>).nodeType ===\n NodeType.Translation\n ) {\n return (\n <TranslationWrapper\n {...props}\n section={section as TranslationContent<DictionaryValue>}\n />\n );\n }\n\n if (\n (section as EnumerationContent<DictionaryValue>).nodeType ===\n NodeType.Enumeration\n ) {\n return (\n <EnumerationWrapper\n {...props}\n section={section as EnumerationContent<DictionaryValue>}\n />\n );\n }\n\n if (Array.isArray(section)) {\n return <ArrayWrapper {...props} section={section as DictionaryValue[]} />;\n }\n\n return (\n <NestedObjectWrapper\n {...props}\n section={section as Record<string, DictionaryValue>}\n />\n );\n }\n\n if (typeof section === 'string') {\n return <StringWrapper {...props} section={section} />;\n }\n};\n"],"names":["NodeType","jsx","ItemLayout","isSameKeyPath","Edit","jsxs","Fragment","createElement","element","useEditedContentStore","StringWrapper"],"mappings":";;;;;;;;;AAgBa,MAAA,eAAsC,CAAC,UAAU;AACtD,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,iBAAiB,CAAC;AAAA,EAChB,IAAA;AAEJ,SAAO,QAAQ,IAAI,CAAC,YAAY,QAAQ;AACtC,UAAM,eAAwB;AAA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