@intlayer/design-system 8.11.3 → 8.12.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/esm/api/hooks/project.mjs +110 -1
- package/dist/esm/api/hooks/project.mjs.map +1 -1
- package/dist/esm/api/hooks/utils.mjs +1 -1
- package/dist/esm/api/index.mjs +2 -2
- package/dist/esm/api/useAuth/useOAuth2.mjs +2 -2
- package/dist/esm/api/useAuth/useSession.mjs +1 -1
- package/dist/esm/api/useIntlayerAPI.mjs +1 -1
- package/dist/esm/components/Accordion/Accordion.mjs.map +1 -1
- package/dist/esm/components/Badge/index.mjs +18 -55
- package/dist/esm/components/Badge/index.mjs.map +1 -1
- package/dist/esm/components/Breadcrumb/index.mjs +12 -12
- package/dist/esm/components/Breadcrumb/index.mjs.map +1 -1
- package/dist/esm/components/Browser/Browser.mjs +1 -1
- package/dist/esm/components/Browser/Browser.mjs.map +1 -1
- package/dist/esm/components/Button/Button.mjs +60 -117
- package/dist/esm/components/Button/Button.mjs.map +1 -1
- package/dist/esm/components/Button/index.mjs +2 -2
- package/dist/esm/components/Carousel/index.mjs +3 -3
- package/dist/esm/components/Carousel/index.mjs.map +1 -1
- package/dist/esm/components/Container/index.mjs +1 -71
- package/dist/esm/components/Container/index.mjs.map +1 -1
- package/dist/esm/components/ContentEditor/ContentEditor.mjs +0 -1
- package/dist/esm/components/ContentEditor/ContentEditor.mjs.map +1 -1
- package/dist/esm/components/ContentEditor/ContentEditorInput.mjs +2 -2
- package/dist/esm/components/ContentEditor/ContentEditorInput.mjs.map +1 -1
- package/dist/esm/components/ContentEditor/ContentEditorTextArea.mjs +2 -2
- package/dist/esm/components/ContentEditor/ContentEditorTextArea.mjs.map +1 -1
- package/dist/esm/components/ContentEditor/index.mjs +1 -1
- package/dist/esm/components/CopyButton/index.mjs +4 -4
- package/dist/esm/components/CopyButton/index.mjs.map +1 -1
- package/dist/esm/components/DictionaryEditor/DictionaryEditor.mjs +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/BooleanWrapper.mjs +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/FileWrapper.mjs +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/NumberWrapper.mjs +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/StringWrapper.mjs +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/index.mjs +1 -1
- package/dist/esm/components/DictionaryFieldEditor/ContentEditor.mjs +1 -1
- package/dist/esm/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs +6 -7
- package/dist/esm/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +0 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +3 -4
- package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +3 -3
- package/dist/esm/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/JSONEditor.mjs +1 -1
- package/dist/esm/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +3 -3
- package/dist/esm/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +3 -4
- package/dist/esm/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/StructureEditor.mjs +1 -1
- package/dist/esm/components/DictionaryFieldEditor/StructureView/StructureView.mjs +2 -3
- package/dist/esm/components/DictionaryFieldEditor/StructureView/StructureView.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcher.mjs +1 -1
- package/dist/esm/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcher.mjs.map +1 -1
- package/dist/esm/components/DropDown/index.mjs +3 -23
- package/dist/esm/components/DropDown/index.mjs.map +1 -1
- package/dist/esm/components/EditableField/EditableFieldLayout.mjs +1 -1
- package/dist/esm/components/EditableField/EditableFieldLayout.mjs.map +1 -1
- package/dist/esm/components/EditableField/EditableFieldTextArea.mjs +1 -1
- package/dist/esm/components/Form/elements/OTPElement.mjs +1 -1
- package/dist/esm/components/IDE/CopyCode.mjs +0 -1
- package/dist/esm/components/IDE/CopyCode.mjs.map +1 -1
- package/dist/esm/components/Input/Checkbox.mjs +2 -22
- package/dist/esm/components/Input/Checkbox.mjs.map +1 -1
- package/dist/esm/components/Input/Input.mjs +1 -11
- package/dist/esm/components/Input/Input.mjs.map +1 -1
- package/dist/esm/components/Input/Radio.mjs +82 -0
- package/dist/esm/components/Input/Radio.mjs.map +1 -0
- package/dist/esm/components/Input/index.mjs +4 -3
- package/dist/esm/components/KeyboardScreenAdapter/index.mjs +1 -1
- package/dist/esm/components/KeyboardShortcut/KeyboardShortcut.mjs +2 -53
- package/dist/esm/components/KeyboardShortcut/KeyboardShortcut.mjs.map +1 -1
- package/dist/esm/components/KeyboardShortcut/index.mjs +2 -2
- package/dist/esm/components/Link/Link.mjs +33 -85
- package/dist/esm/components/Link/Link.mjs.map +1 -1
- package/dist/esm/components/Link/index.mjs +2 -2
- package/dist/esm/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs +3 -3
- package/dist/esm/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs.map +1 -1
- package/dist/esm/components/LocaleSwitcherDropDown/LocaleSwitcher.mjs +1 -1
- package/dist/esm/components/LocaleSwitcherDropDown/LocaleSwitcher.mjs.map +1 -1
- package/dist/esm/components/MarkDownRender/MarkDownIframe.mjs +3 -3
- package/dist/esm/components/MarkDownRender/MarkDownIframe.mjs.map +1 -1
- package/dist/esm/components/Modal/Modal.mjs +5 -16
- package/dist/esm/components/Modal/Modal.mjs.map +1 -1
- package/dist/esm/components/Modal/index.mjs +2 -2
- package/dist/esm/components/Navbar/DesktopNavbar.mjs +1 -1
- package/dist/esm/components/Navbar/DesktopNavbar.mjs.map +1 -1
- package/dist/esm/components/Navbar/MobileNavbar.mjs +2 -2
- package/dist/esm/components/Pagination/Pagination.mjs +3 -15
- package/dist/esm/components/Pagination/Pagination.mjs.map +1 -1
- package/dist/esm/components/Pagination/index.mjs +2 -2
- package/dist/esm/components/Pattern/DotPattern.mjs +1 -1
- package/dist/esm/components/Pattern/DotPattern.mjs.map +1 -1
- package/dist/esm/components/Popover/dynamic.mjs +4 -4
- package/dist/esm/components/Popover/dynamic.mjs.map +1 -1
- package/dist/esm/components/Popover/index.mjs +2 -2
- package/dist/esm/components/Popover/static.mjs +6 -28
- package/dist/esm/components/Popover/static.mjs.map +1 -1
- package/dist/esm/components/RightDrawer/RightDrawer.mjs +4 -4
- package/dist/esm/components/RightDrawer/RightDrawer.mjs.map +1 -1
- package/dist/esm/components/Select/Multiselect.mjs +4 -4
- package/dist/esm/components/Select/Multiselect.mjs.map +1 -1
- package/dist/esm/components/Select/Select.mjs +3 -15
- package/dist/esm/components/Select/Select.mjs.map +1 -1
- package/dist/esm/components/Select/index.mjs +2 -2
- package/dist/esm/components/Steps/index.mjs +37 -27
- package/dist/esm/components/Steps/index.mjs.map +1 -1
- package/dist/esm/components/Steps/steps.content.mjs +55 -0
- package/dist/esm/components/Steps/steps.content.mjs.map +1 -0
- package/dist/esm/components/SwitchSelector/SwitchSelector.mjs +19 -35
- package/dist/esm/components/SwitchSelector/SwitchSelector.mjs.map +1 -1
- package/dist/esm/components/SwitchSelector/VerticalSwitchSelector.mjs +20 -20
- package/dist/esm/components/SwitchSelector/VerticalSwitchSelector.mjs.map +1 -1
- package/dist/esm/components/SwitchSelector/index.mjs +2 -2
- package/dist/esm/components/Tab/Tab.mjs +3 -3
- package/dist/esm/components/Tab/Tab.mjs.map +1 -1
- package/dist/esm/components/TabSelector/TabSelector.mjs +2 -12
- package/dist/esm/components/TabSelector/TabSelector.mjs.map +1 -1
- package/dist/esm/components/TabSelector/index.mjs +2 -2
- package/dist/esm/components/Table/ExpandButton.mjs +0 -1
- package/dist/esm/components/Table/ExpandButton.mjs.map +1 -1
- package/dist/esm/components/Table/SmartTable.mjs +1 -1
- package/dist/esm/components/Table/SmartTable.mjs.map +1 -1
- package/dist/esm/components/Tag/index.mjs +51 -205
- package/dist/esm/components/Tag/index.mjs.map +1 -1
- package/dist/esm/components/TechLogo/TechLogo.mjs +36 -37
- package/dist/esm/components/TechLogo/TechLogo.mjs.map +1 -1
- package/dist/esm/components/TechLogo/index.mjs +1 -2
- package/dist/esm/components/TechLogo/types.mjs +0 -44
- package/dist/esm/components/TextArea/AutoSizeTextArea.mjs +1 -1
- package/dist/esm/components/TextArea/AutoSizeTextArea.mjs.map +1 -1
- package/dist/esm/components/TextArea/ContentEditableTextArea.mjs.map +1 -1
- package/dist/esm/components/TextArea/TextArea.mjs +2 -2
- package/dist/esm/components/TextArea/TextArea.mjs.map +1 -1
- package/dist/esm/components/TextArea/index.mjs +2 -2
- package/dist/esm/components/ThemeSwitcherDropDown/DesktopThemeSwitcher.mjs +1 -2
- package/dist/esm/components/ThemeSwitcherDropDown/DesktopThemeSwitcher.mjs.map +1 -1
- package/dist/esm/components/ThemeSwitcherDropDown/MobileThemeSwitcher.mjs +0 -1
- package/dist/esm/components/ThemeSwitcherDropDown/MobileThemeSwitcher.mjs.map +1 -1
- package/dist/esm/components/ThemeSwitcherDropDown/index.mjs +1 -2
- package/dist/esm/components/ThemeSwitcherDropDown/types.mjs +0 -11
- package/dist/esm/components/index.mjs +24 -23
- package/dist/esm/hooks/index.mjs +8 -8
- package/dist/esm/providers/ReactQueryProvider.mjs +2 -2
- package/dist/types/api/hooks/project.d.ts +8 -1
- package/dist/types/api/hooks/project.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +2 -2
- package/dist/types/api/useIntlayerAPI.d.ts +9 -2
- package/dist/types/api/useIntlayerAPI.d.ts.map +1 -1
- package/dist/types/components/Accordion/Accordion.d.ts.map +1 -1
- package/dist/types/components/Badge/index.d.ts +6 -25
- package/dist/types/components/Badge/index.d.ts.map +1 -1
- package/dist/types/components/Breadcrumb/index.d.ts +1 -1
- package/dist/types/components/Browser/Browser.d.ts +1 -1
- package/dist/types/components/Browser/Browser.d.ts.map +1 -1
- package/dist/types/components/Button/Button.d.ts +9 -45
- package/dist/types/components/Button/Button.d.ts.map +1 -1
- package/dist/types/components/Carousel/index.d.ts.map +1 -1
- package/dist/types/components/CollapsibleTable/CollapsibleTable.d.ts +2 -2
- package/dist/types/components/Command/index.d.ts +2 -2
- package/dist/types/components/Command/index.d.ts.map +1 -1
- package/dist/types/components/Container/index.d.ts +11 -60
- package/dist/types/components/Container/index.d.ts.map +1 -1
- package/dist/types/components/ContentEditor/ContentEditor.d.ts.map +1 -1
- package/dist/types/components/CopyButton/index.d.ts +3 -3
- package/dist/types/components/CopyButton/index.d.ts.map +1 -1
- package/dist/types/components/DictionaryFieldEditor/ContentEditorView/SafeHtmlRenderer.d.ts +1 -1
- package/dist/types/components/DictionaryFieldEditor/ContentEditorView/SafeHtmlRenderer.d.ts.map +1 -1
- package/dist/types/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts.map +1 -1
- package/dist/types/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.d.ts.map +1 -1
- package/dist/types/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.d.ts.map +1 -1
- package/dist/types/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts.map +1 -1
- package/dist/types/components/DictionaryFieldEditor/StructureView/StructureView.d.ts.map +1 -1
- package/dist/types/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcher.d.ts.map +1 -1
- package/dist/types/components/DropDown/index.d.ts +4 -14
- package/dist/types/components/DropDown/index.d.ts.map +1 -1
- package/dist/types/components/Form/FormBase.d.ts +1 -1
- package/dist/types/components/Form/FormBase.d.ts.map +1 -1
- package/dist/types/components/Form/FormField.d.ts +1 -1
- package/dist/types/components/Form/FormField.d.ts.map +1 -1
- package/dist/types/components/Form/elements/EditableFieldInputElement.d.ts +1 -1
- package/dist/types/components/Form/elements/EditableFieldInputElement.d.ts.map +1 -1
- package/dist/types/components/Form/elements/EditableFieldTextAreaElement.d.ts +1 -1
- package/dist/types/components/Form/elements/EditableFieldTextAreaElement.d.ts.map +1 -1
- package/dist/types/components/Form/elements/FormElement.d.ts +1 -1
- package/dist/types/components/Form/elements/FormElement.d.ts.map +1 -1
- package/dist/types/components/Form/elements/MultiselectElement.d.ts +1 -1
- package/dist/types/components/Form/elements/MultiselectElement.d.ts.map +1 -1
- package/dist/types/components/Form/elements/OTPElement.d.ts +1 -1
- package/dist/types/components/Form/elements/OTPElement.d.ts.map +1 -1
- package/dist/types/components/Form/elements/SelectElement.d.ts +1 -1
- package/dist/types/components/Form/elements/SelectElement.d.ts.map +1 -1
- package/dist/types/components/Form/elements/SwitchSelectorElement.d.ts +1 -1
- package/dist/types/components/Form/elements/SwitchSelectorElement.d.ts.map +1 -1
- package/dist/types/components/IDE/CodeBlockHighlight.d.ts +1 -1
- package/dist/types/components/IDE/CodeBlockHighlight.d.ts.map +1 -1
- package/dist/types/components/Input/Checkbox.d.ts +4 -20
- package/dist/types/components/Input/Checkbox.d.ts.map +1 -1
- package/dist/types/components/Input/Input.d.ts +3 -9
- package/dist/types/components/Input/Input.d.ts.map +1 -1
- package/dist/types/components/Input/OTPInput.d.ts +1 -1
- package/dist/types/components/Input/OTPInput.d.ts.map +1 -1
- package/dist/types/components/Input/Radio.d.ts +25 -0
- package/dist/types/components/Input/Radio.d.ts.map +1 -0
- package/dist/types/components/Input/SearchInput.d.ts +1 -1
- package/dist/types/components/Input/SearchInput.d.ts.map +1 -1
- package/dist/types/components/Input/index.d.ts +2 -1
- package/dist/types/components/KeyboardShortcut/KeyboardShortcut.d.ts +1 -47
- package/dist/types/components/KeyboardShortcut/KeyboardShortcut.d.ts.map +1 -1
- package/dist/types/components/Link/Link.d.ts +8 -47
- package/dist/types/components/Link/Link.d.ts.map +1 -1
- package/dist/types/components/Loader/spinner.d.ts +1 -1
- package/dist/types/components/Loader/spinner.d.ts.map +1 -1
- package/dist/types/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.d.ts.map +1 -1
- package/dist/types/components/MarkDownRender/MarkDownRender.d.ts +44 -44
- package/dist/types/components/MarkDownRender/MarkDownRender.d.ts.map +1 -1
- package/dist/types/components/MaxWidthSmoother/index.d.ts +1 -1
- package/dist/types/components/MaxWidthSmoother/index.d.ts.map +1 -1
- package/dist/types/components/Modal/Modal.d.ts +2 -8
- package/dist/types/components/Modal/Modal.d.ts.map +1 -1
- package/dist/types/components/Navbar/Burger.d.ts +1 -1
- package/dist/types/components/Navbar/Burger.d.ts.map +1 -1
- package/dist/types/components/Navbar/DesktopNavbar.d.ts +1 -1
- package/dist/types/components/Navbar/DesktopNavbar.d.ts.map +1 -1
- package/dist/types/components/Navbar/MobileNavbar.d.ts +1 -1
- package/dist/types/components/Navbar/MobileNavbar.d.ts.map +1 -1
- package/dist/types/components/Navbar/index.d.ts +1 -1
- package/dist/types/components/Navbar/index.d.ts.map +1 -1
- package/dist/types/components/Pagination/Pagination.d.ts +2 -10
- package/dist/types/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/types/components/Popover/dynamic.d.ts.map +1 -1
- package/dist/types/components/Popover/static.d.ts +5 -17
- package/dist/types/components/Popover/static.d.ts.map +1 -1
- package/dist/types/components/Select/Multiselect.d.ts +3 -3
- package/dist/types/components/Select/Select.d.ts +3 -8
- package/dist/types/components/Select/Select.d.ts.map +1 -1
- package/dist/types/components/SocialNetworks/index.d.ts +1 -1
- package/dist/types/components/Steps/index.d.ts +4 -4
- package/dist/types/components/Steps/index.d.ts.map +1 -1
- package/dist/types/components/Steps/steps.content.d.ts +52 -0
- package/dist/types/components/Steps/steps.content.d.ts.map +1 -0
- package/dist/types/components/SwitchSelector/SwitchSelector.d.ts +4 -16
- package/dist/types/components/SwitchSelector/SwitchSelector.d.ts.map +1 -1
- package/dist/types/components/SwitchSelector/VerticalSwitchSelector.d.ts +2 -2
- package/dist/types/components/SwitchSelector/VerticalSwitchSelector.d.ts.map +1 -1
- package/dist/types/components/Tab/Tab.d.ts +2 -2
- package/dist/types/components/Tab/Tab.d.ts.map +1 -1
- package/dist/types/components/TabSelector/TabSelector.d.ts +2 -10
- package/dist/types/components/TabSelector/TabSelector.d.ts.map +1 -1
- package/dist/types/components/Table/TableElements.d.ts +4 -4
- package/dist/types/components/Table/TableElements.d.ts.map +1 -1
- package/dist/types/components/Tag/index.d.ts +44 -83
- package/dist/types/components/Tag/index.d.ts.map +1 -1
- package/dist/types/components/TechLogo/TechLogo.d.ts.map +1 -1
- package/dist/types/components/TechLogo/index.d.ts +1 -1
- package/dist/types/components/TechLogo/logos/Lit.d.ts +1 -1
- package/dist/types/components/TechLogo/logos/Lit.d.ts.map +1 -1
- package/dist/types/components/TechLogo/logos/Vanilla.d.ts +1 -1
- package/dist/types/components/TechLogo/logos/Vanilla.d.ts.map +1 -1
- package/dist/types/components/TechLogo/types.d.ts +1 -38
- package/dist/types/components/TechLogo/types.d.ts.map +1 -1
- package/dist/types/components/TextArea/AutoSizeTextArea.d.ts +1 -1
- package/dist/types/components/TextArea/ContentEditableTextArea.d.ts +3 -3
- package/dist/types/components/TextArea/TextArea.d.ts +6 -6
- package/dist/types/components/TextArea/TextArea.d.ts.map +1 -1
- package/dist/types/components/ThemeSwitcherDropDown/types.d.ts +1 -5
- package/dist/types/components/ThemeSwitcherDropDown/types.d.ts.map +1 -1
- package/dist/types/components/Toaster/Toast.d.ts +1 -1
- package/dist/types/components/Toaster/Toaster.d.ts +1 -1
- package/dist/types/components/Toaster/Toaster.d.ts.map +1 -1
- package/dist/types/components/index.d.ts +5 -2
- package/package.json +23 -24
- package/dist/esm/components/TechLogo/types.mjs.map +0 -1
- package/dist/esm/components/ThemeSwitcherDropDown/types.mjs.map +0 -1
|
@@ -157,6 +157,107 @@ const useTriggerWebhook = () => {
|
|
|
157
157
|
meta: { invalidateQueries: [["projects"]] }
|
|
158
158
|
});
|
|
159
159
|
};
|
|
160
|
+
const useAddEnvironment = () => {
|
|
161
|
+
const projectAPI = useProjectAPI();
|
|
162
|
+
const queryClient = useQueryClient();
|
|
163
|
+
return useMutation({
|
|
164
|
+
mutationKey: ["projects", "environments"],
|
|
165
|
+
mutationFn: (args) => projectAPI.addEnvironment(args),
|
|
166
|
+
onSuccess: (data) => {
|
|
167
|
+
const session = queryClient.getQueryData(["session"]);
|
|
168
|
+
queryClient.setQueryData(["session"], {
|
|
169
|
+
...session ?? {},
|
|
170
|
+
project: {
|
|
171
|
+
...session?.project ?? {},
|
|
172
|
+
environments: data.data
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
queryClient.invalidateQueries({ queryKey: ["projects"] });
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
const useUpdateEnvironment = () => {
|
|
180
|
+
const projectAPI = useProjectAPI();
|
|
181
|
+
const queryClient = useQueryClient();
|
|
182
|
+
return useMutation({
|
|
183
|
+
mutationKey: ["projects", "environments"],
|
|
184
|
+
mutationFn: ({ environmentId, ...body }) => projectAPI.updateEnvironment(environmentId, body),
|
|
185
|
+
onSuccess: (data) => {
|
|
186
|
+
const session = queryClient.getQueryData(["session"]);
|
|
187
|
+
queryClient.setQueryData(["session"], {
|
|
188
|
+
...session ?? {},
|
|
189
|
+
project: {
|
|
190
|
+
...session?.project ?? {},
|
|
191
|
+
environments: data.data
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
queryClient.invalidateQueries({ queryKey: ["projects"] });
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
const useDeleteEnvironment = () => {
|
|
199
|
+
const projectAPI = useProjectAPI();
|
|
200
|
+
const queryClient = useQueryClient();
|
|
201
|
+
return useMutation({
|
|
202
|
+
mutationKey: ["projects", "environments"],
|
|
203
|
+
mutationFn: (environmentId) => projectAPI.deleteEnvironment(environmentId),
|
|
204
|
+
onSuccess: (data) => {
|
|
205
|
+
const session = queryClient.getQueryData(["session"]);
|
|
206
|
+
queryClient.setQueryData(["session"], {
|
|
207
|
+
...session ?? {},
|
|
208
|
+
project: {
|
|
209
|
+
...session?.project ?? {},
|
|
210
|
+
environments: data.data
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
queryClient.invalidateQueries({ queryKey: ["projects", "dictionaries"] });
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
const useSelectEnvironment = () => {
|
|
218
|
+
const projectAPI = useProjectAPI();
|
|
219
|
+
const queryClient = useQueryClient();
|
|
220
|
+
return useMutation({
|
|
221
|
+
mutationKey: ["session-environment"],
|
|
222
|
+
mutationFn: (environmentId) => projectAPI.selectEnvironment(environmentId),
|
|
223
|
+
onSuccess: (data) => {
|
|
224
|
+
const session = queryClient.getQueryData(["session"]);
|
|
225
|
+
queryClient.setQueryData(["session"], {
|
|
226
|
+
...session ?? {},
|
|
227
|
+
environment: data.data
|
|
228
|
+
});
|
|
229
|
+
queryClient.invalidateQueries({ queryKey: ["dictionaries"] });
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
};
|
|
233
|
+
const useResetToProductionEnvironment = () => {
|
|
234
|
+
const projectAPI = useProjectAPI();
|
|
235
|
+
const queryClient = useQueryClient();
|
|
236
|
+
return useMutation({
|
|
237
|
+
mutationKey: ["session-environment"],
|
|
238
|
+
mutationFn: () => projectAPI.resetToProductionEnvironment(),
|
|
239
|
+
onSuccess: (data) => {
|
|
240
|
+
const session = queryClient.getQueryData(["session"]);
|
|
241
|
+
queryClient.setQueryData(["session"], {
|
|
242
|
+
...session ?? {},
|
|
243
|
+
environment: data.data
|
|
244
|
+
});
|
|
245
|
+
queryClient.invalidateQueries({ queryKey: ["dictionaries"] });
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
};
|
|
249
|
+
const useMigrateEnvironment = () => {
|
|
250
|
+
const projectAPI = useProjectAPI();
|
|
251
|
+
return useMutation({
|
|
252
|
+
mutationKey: [
|
|
253
|
+
"projects",
|
|
254
|
+
"environments",
|
|
255
|
+
"migrate"
|
|
256
|
+
],
|
|
257
|
+
mutationFn: (args) => projectAPI.migrateEnvironment(args),
|
|
258
|
+
meta: { invalidateQueries: [["dictionaries"]] }
|
|
259
|
+
});
|
|
260
|
+
};
|
|
160
261
|
const useAddNewAccessKey = () => {
|
|
161
262
|
const projectAPI = useProjectAPI();
|
|
162
263
|
return useMutation({
|
|
@@ -181,7 +282,15 @@ const useRefreshAccessKey = () => {
|
|
|
181
282
|
meta: { invalidateQueries: [["session"]] }
|
|
182
283
|
});
|
|
183
284
|
};
|
|
285
|
+
const useUpdateMemberAccess = () => {
|
|
286
|
+
const projectAPI = useProjectAPI();
|
|
287
|
+
return useMutation({
|
|
288
|
+
mutationKey: ["projects", "member-access"],
|
|
289
|
+
mutationFn: ({ userId, ...body }) => projectAPI.updateMemberAccess(userId, body),
|
|
290
|
+
meta: { invalidateQueries: [["projects"], ["session"]] }
|
|
291
|
+
});
|
|
292
|
+
};
|
|
184
293
|
|
|
185
294
|
//#endregion
|
|
186
|
-
export { useAddNewAccessKey, useAddProject, useDeleteAccessKey, useDeleteProject, useDeleteProjectById, useGetCIConfig, useGetProjects, usePushCIConfig, usePushProjectConfiguration, useRefreshAccessKey, useSelectProject, useTriggerBuild, useTriggerWebhook, useUnselectProject, useUpdateProject, useUpdateProjectMembers };
|
|
295
|
+
export { useAddEnvironment, useAddNewAccessKey, useAddProject, useDeleteAccessKey, useDeleteEnvironment, useDeleteProject, useDeleteProjectById, useGetCIConfig, useGetProjects, useMigrateEnvironment, usePushCIConfig, usePushProjectConfiguration, useRefreshAccessKey, useResetToProductionEnvironment, useSelectEnvironment, useSelectProject, useTriggerBuild, useTriggerWebhook, useUnselectProject, useUpdateEnvironment, useUpdateMemberAccess, useUpdateProject, useUpdateProjectMembers };
|
|
187
296
|
//# sourceMappingURL=project.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.mjs","names":[],"sources":["../../../../src/api/hooks/project.ts"],"sourcesContent":["'use client';\n\nimport type {\n AddNewAccessKeyBody,\n AddProjectBody,\n DeleteAccessKeyBody,\n GetProjectsParams,\n PushProjectConfigurationBody,\n RefreshAccessKeyBody,\n SelectProjectParam,\n UpdateProjectBody,\n UpdateProjectMembersBody,\n} from '@intlayer/backend';\nimport {\n type UseQueryOptions,\n useMutation,\n useQueryClient,\n} from '@tanstack/react-query';\nimport { useProjectAPI } from '../useIntlayerAPI';\nimport { useAppQuery } from './utils';\n\nexport const useGetProjects = (\n filters?: GetProjectsParams,\n options?: Partial<UseQueryOptions>\n) => {\n const projectAPI = useProjectAPI();\n\n return useAppQuery({\n queryKey: ['projects', filters],\n queryFn: ({ signal }) => projectAPI.getProjects(filters, { signal }),\n // placeholderData: keepPreviousData,\n requireUser: true,\n requireOrganization: true,\n ...options,\n });\n};\n\nexport const useAddProject = () => {\n const projectAPI = useProjectAPI();\n\n return useMutation({\n mutationKey: ['projects'],\n mutationFn: (args: AddProjectBody) => projectAPI.addProject(args),\n meta: {\n invalidateQueries: [['projects']],\n },\n });\n};\n\nexport const useUpdateProject = () => {\n const projectAPI = useProjectAPI();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationKey: ['projects'],\n mutationFn: (args: UpdateProjectBody) => projectAPI.updateProject(args),\n meta: {\n invalidateQueries: [['projects']],\n },\n onSuccess: (data) => {\n const session = queryClient.getQueryData(['session']);\n\n queryClient.setQueryData(['session'], {\n ...(session ?? {}),\n project: data.data,\n });\n },\n });\n};\n\nexport const usePushProjectConfiguration = () => {\n const projectAPI = useProjectAPI();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationKey: ['project', 'push-configuration'],\n mutationFn: (args: PushProjectConfigurationBody) =>\n projectAPI.pushProjectConfiguration(args),\n onSuccess: (data) => {\n const session = queryClient.getQueryData(['session']);\n\n queryClient.setQueryData(['session'], {\n ...(session ?? {}),\n project: data.data,\n });\n },\n });\n};\n\nexport const useUpdateProjectMembers = () => {\n const projectAPI = useProjectAPI();\n\n return useMutation({\n mutationKey: ['projects'],\n mutationFn: (args: UpdateProjectMembersBody) =>\n projectAPI.updateProjectMembers(args),\n meta: {\n invalidateQueries: [['projects']],\n },\n });\n};\n\nexport const useDeleteProject = () => {\n const projectAPI = useProjectAPI();\n\n return useMutation({\n mutationKey: ['projects'],\n mutationFn: () => projectAPI.deleteProject(),\n meta: {\n invalidateQueries: [['projects']],\n },\n });\n};\n\nexport const useDeleteProjectById = () => {\n const projectAPI = useProjectAPI();\n\n return useMutation({\n mutationKey: ['projects'],\n mutationFn: (projectId: string) =>\n projectAPI.deleteProjectByIdAdmin(projectId),\n meta: {\n invalidateQueries: [['projects']],\n },\n });\n};\n\nexport const useSelectProject = () => {\n const projectAPI = useProjectAPI();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationKey: ['session-projects'],\n mutationFn: (args: SelectProjectParam) => projectAPI.selectProject(args),\n meta: {\n invalidateQueries: [\n ['session'],\n ['projects'],\n ['dictionaries'],\n ['tags'],\n ['subscription'],\n ['users'],\n ],\n },\n onSuccess: (data) => {\n const session = queryClient.getQueryData(['session']);\n\n queryClient.setQueryData(['session'], {\n ...(session ?? {}),\n project: data.data,\n });\n },\n });\n};\n\nexport const useUnselectProject = () => {\n const projectAPI = useProjectAPI();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationKey: ['session-projects'],\n mutationFn: () => projectAPI.unselectProject(),\n meta: {\n resetQueries: [\n ['session'],\n ['projects'],\n ['dictionaries'],\n ['tags'],\n ['subscription'],\n ['users'],\n ],\n },\n onSuccess: () => {\n const session = queryClient.getQueryData(['session']);\n\n queryClient.setQueryData(['session'], {\n ...(session ?? {}),\n project: null,\n });\n },\n });\n};\n\nexport const useGetCIConfig = (options?: Partial<UseQueryOptions>) => {\n const projectAPI = useProjectAPI();\n\n return useAppQuery({\n queryKey: ['ci-config'],\n queryFn: ({ signal }) => projectAPI.getCIConfig({ signal }),\n requireProject: true,\n ...options,\n });\n};\n\nexport const usePushCIConfig = () => {\n const projectAPI = useProjectAPI();\n\n return useMutation({\n mutationKey: ['ci-config'],\n mutationFn: () => projectAPI.pushCIConfig(),\n meta: {\n invalidateQueries: [['ci-config']],\n },\n });\n};\n\nexport const useTriggerBuild = () => {\n const projectAPI = useProjectAPI();\n\n return useMutation({\n mutationKey: ['projects', 'build'],\n mutationFn: () => projectAPI.triggerBuild(),\n meta: {\n invalidateQueries: [['projects']],\n },\n });\n};\n\nexport const useTriggerWebhook = () => {\n const projectAPI = useProjectAPI();\n\n return useMutation({\n mutationKey: ['projects', 'webhook'],\n mutationFn: (webhookIndex: number) =>\n projectAPI.triggerWebhook(webhookIndex),\n meta: {\n invalidateQueries: [['projects']],\n },\n });\n};\n\nexport const useAddNewAccessKey = () => {\n const projectAPI = useProjectAPI();\n\n return useMutation({\n mutationKey: ['session', 'access-keys'],\n mutationFn: (args: AddNewAccessKeyBody) => projectAPI.addNewAccessKey(args),\n meta: {\n invalidateQueries: [['session']],\n },\n });\n};\n\nexport const useDeleteAccessKey = () => {\n const projectAPI = useProjectAPI();\n\n return useMutation({\n mutationKey: ['session', 'access-keys'],\n mutationFn: (args: DeleteAccessKeyBody) => projectAPI.deleteAccessKey(args),\n meta: {\n invalidateQueries: [['session']],\n },\n });\n};\n\nexport const useRefreshAccessKey = () => {\n const projectAPI = useProjectAPI();\n\n return useMutation({\n mutationKey: ['session', 'access-keys'],\n mutationFn: (args: RefreshAccessKeyBody) =>\n projectAPI.refreshAccessKey(args),\n meta: {\n invalidateQueries: [['session']],\n },\n });\n};\n"],"mappings":";;;;;;;AAqBA,MAAa,kBACX,SACA,YACG;CACH,MAAM,aAAa,cAAc;CAEjC,O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MAAM,EACJ,mBAAmB,CAAC,CAAC,SAAS,CAAC,EACjC;CACF,CAAC;AACH;AAEA,MAAa,4BAA4B;CACvC,MAAM,aAAa,cAAc;CAEjC,OAAO,YAAY;EACjB,aAAa,CAAC,WAAW,aAAa;EACtC,aAAa,SACX,WAAW,iBAAiB,IAAI;EAClC,MAAM,EACJ,mBAAmB,CAAC,CAAC,SAAS,CAAC,EACjC;CACF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"project.mjs","names":[],"sources":["../../../../src/api/hooks/project.ts"],"sourcesContent":["'use client';\n\nimport type {\n AddEnvironmentBody,\n AddNewAccessKeyBody,\n AddProjectBody,\n DeleteAccessKeyBody,\n GetProjectsParams,\n MigrateEnvironmentBody,\n PushProjectConfigurationBody,\n RefreshAccessKeyBody,\n SelectProjectParam,\n UpdateEnvironmentBody,\n UpdateMemberAccessBody,\n UpdateProjectBody,\n UpdateProjectMembersBody,\n} from '@intlayer/backend';\nimport {\n type UseQueryOptions,\n useMutation,\n useQueryClient,\n} from '@tanstack/react-query';\nimport { useProjectAPI } from '../useIntlayerAPI';\nimport { useAppQuery } from './utils';\n\nexport const useGetProjects = (\n filters?: GetProjectsParams,\n options?: Partial<UseQueryOptions>\n) => {\n const projectAPI = useProjectAPI();\n\n return useAppQuery({\n queryKey: ['projects', filters],\n queryFn: ({ signal }) => projectAPI.getProjects(filters, { signal }),\n // placeholderData: keepPreviousData,\n requireUser: true,\n requireOrganization: true,\n ...options,\n });\n};\n\nexport const useAddProject = () => {\n const projectAPI = useProjectAPI();\n\n return useMutation({\n mutationKey: ['projects'],\n mutationFn: (args: AddProjectBody) => projectAPI.addProject(args),\n meta: {\n invalidateQueries: [['projects']],\n },\n });\n};\n\nexport const useUpdateProject = () => {\n const projectAPI = useProjectAPI();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationKey: ['projects'],\n mutationFn: (args: UpdateProjectBody) => projectAPI.updateProject(args),\n meta: {\n invalidateQueries: [['projects']],\n },\n onSuccess: (data) => {\n const session = queryClient.getQueryData(['session']);\n\n queryClient.setQueryData(['session'], {\n ...(session ?? {}),\n project: data.data,\n });\n },\n });\n};\n\nexport const usePushProjectConfiguration = () => {\n const projectAPI = useProjectAPI();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationKey: ['project', 'push-configuration'],\n mutationFn: (args: PushProjectConfigurationBody) =>\n projectAPI.pushProjectConfiguration(args),\n onSuccess: (data) => {\n const session = queryClient.getQueryData(['session']);\n\n queryClient.setQueryData(['session'], {\n ...(session ?? {}),\n project: data.data,\n });\n },\n });\n};\n\nexport const useUpdateProjectMembers = () => {\n const projectAPI = useProjectAPI();\n\n return useMutation({\n mutationKey: ['projects'],\n mutationFn: (args: UpdateProjectMembersBody) =>\n projectAPI.updateProjectMembers(args),\n meta: {\n invalidateQueries: [['projects']],\n },\n });\n};\n\nexport const useDeleteProject = () => {\n const projectAPI = useProjectAPI();\n\n return useMutation({\n mutationKey: ['projects'],\n mutationFn: () => projectAPI.deleteProject(),\n meta: {\n invalidateQueries: [['projects']],\n },\n });\n};\n\nexport const useDeleteProjectById = () => {\n const projectAPI = useProjectAPI();\n\n return useMutation({\n mutationKey: ['projects'],\n mutationFn: (projectId: string) =>\n projectAPI.deleteProjectByIdAdmin(projectId),\n meta: {\n invalidateQueries: [['projects']],\n },\n });\n};\n\nexport const useSelectProject = () => {\n const projectAPI = useProjectAPI();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationKey: ['session-projects'],\n mutationFn: (args: SelectProjectParam) => projectAPI.selectProject(args),\n meta: {\n invalidateQueries: [\n ['session'],\n ['projects'],\n ['dictionaries'],\n ['tags'],\n ['subscription'],\n ['users'],\n ],\n },\n onSuccess: (data) => {\n const session = queryClient.getQueryData(['session']);\n\n queryClient.setQueryData(['session'], {\n ...(session ?? {}),\n project: data.data,\n });\n },\n });\n};\n\nexport const useUnselectProject = () => {\n const projectAPI = useProjectAPI();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationKey: ['session-projects'],\n mutationFn: () => projectAPI.unselectProject(),\n meta: {\n resetQueries: [\n ['session'],\n ['projects'],\n ['dictionaries'],\n ['tags'],\n ['subscription'],\n ['users'],\n ],\n },\n onSuccess: () => {\n const session = queryClient.getQueryData(['session']);\n\n queryClient.setQueryData(['session'], {\n ...(session ?? {}),\n project: null,\n });\n },\n });\n};\n\nexport const useGetCIConfig = (options?: Partial<UseQueryOptions>) => {\n const projectAPI = useProjectAPI();\n\n return useAppQuery({\n queryKey: ['ci-config'],\n queryFn: ({ signal }) => projectAPI.getCIConfig({ signal }),\n requireProject: true,\n ...options,\n });\n};\n\nexport const usePushCIConfig = () => {\n const projectAPI = useProjectAPI();\n\n return useMutation({\n mutationKey: ['ci-config'],\n mutationFn: () => projectAPI.pushCIConfig(),\n meta: {\n invalidateQueries: [['ci-config']],\n },\n });\n};\n\nexport const useTriggerBuild = () => {\n const projectAPI = useProjectAPI();\n\n return useMutation({\n mutationKey: ['projects', 'build'],\n mutationFn: () => projectAPI.triggerBuild(),\n meta: {\n invalidateQueries: [['projects']],\n },\n });\n};\n\nexport const useTriggerWebhook = () => {\n const projectAPI = useProjectAPI();\n\n return useMutation({\n mutationKey: ['projects', 'webhook'],\n mutationFn: (webhookIndex: number) =>\n projectAPI.triggerWebhook(webhookIndex),\n meta: {\n invalidateQueries: [['projects']],\n },\n });\n};\n\nexport const useAddEnvironment = () => {\n const projectAPI = useProjectAPI();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationKey: ['projects', 'environments'],\n mutationFn: (args: AddEnvironmentBody) => projectAPI.addEnvironment(args),\n onSuccess: (data) => {\n const session = queryClient.getQueryData(['session']);\n queryClient.setQueryData(['session'], {\n ...(session ?? {}),\n project: {\n ...((session as any)?.project ?? {}),\n environments: data.data,\n },\n });\n queryClient.invalidateQueries({ queryKey: ['projects'] });\n },\n });\n};\n\nexport const useUpdateEnvironment = () => {\n const projectAPI = useProjectAPI();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationKey: ['projects', 'environments'],\n mutationFn: ({\n environmentId,\n ...body\n }: UpdateEnvironmentBody & { environmentId: string }) =>\n projectAPI.updateEnvironment(environmentId, body),\n onSuccess: (data) => {\n const session = queryClient.getQueryData(['session']);\n queryClient.setQueryData(['session'], {\n ...(session ?? {}),\n project: {\n ...((session as any)?.project ?? {}),\n environments: data.data,\n },\n });\n queryClient.invalidateQueries({ queryKey: ['projects'] });\n },\n });\n};\n\nexport const useDeleteEnvironment = () => {\n const projectAPI = useProjectAPI();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationKey: ['projects', 'environments'],\n mutationFn: (environmentId: string) =>\n projectAPI.deleteEnvironment(environmentId),\n onSuccess: (data) => {\n const session = queryClient.getQueryData(['session']);\n queryClient.setQueryData(['session'], {\n ...(session ?? {}),\n project: {\n ...((session as any)?.project ?? {}),\n environments: data.data,\n },\n });\n queryClient.invalidateQueries({ queryKey: ['projects', 'dictionaries'] });\n },\n });\n};\n\nexport const useSelectEnvironment = () => {\n const projectAPI = useProjectAPI();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationKey: ['session-environment'],\n mutationFn: (environmentId: string) =>\n projectAPI.selectEnvironment(environmentId),\n onSuccess: (data) => {\n const session = queryClient.getQueryData(['session']);\n queryClient.setQueryData(['session'], {\n ...(session ?? {}),\n environment: data.data,\n });\n queryClient.invalidateQueries({ queryKey: ['dictionaries'] });\n },\n });\n};\n\nexport const useResetToProductionEnvironment = () => {\n const projectAPI = useProjectAPI();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationKey: ['session-environment'],\n mutationFn: () => projectAPI.resetToProductionEnvironment(),\n onSuccess: (data) => {\n const session = queryClient.getQueryData(['session']);\n queryClient.setQueryData(['session'], {\n ...(session ?? {}),\n environment: data.data,\n });\n queryClient.invalidateQueries({ queryKey: ['dictionaries'] });\n },\n });\n};\n\nexport const useMigrateEnvironment = () => {\n const projectAPI = useProjectAPI();\n\n return useMutation({\n mutationKey: ['projects', 'environments', 'migrate'],\n mutationFn: (args: MigrateEnvironmentBody) =>\n projectAPI.migrateEnvironment(args),\n meta: {\n invalidateQueries: [['dictionaries']],\n },\n });\n};\n\nexport const useAddNewAccessKey = () => {\n const projectAPI = useProjectAPI();\n\n return useMutation({\n mutationKey: ['session', 'access-keys'],\n mutationFn: (args: AddNewAccessKeyBody) => projectAPI.addNewAccessKey(args),\n meta: {\n invalidateQueries: [['session']],\n },\n });\n};\n\nexport const useDeleteAccessKey = () => {\n const projectAPI = useProjectAPI();\n\n return useMutation({\n mutationKey: ['session', 'access-keys'],\n mutationFn: (args: DeleteAccessKeyBody) => projectAPI.deleteAccessKey(args),\n meta: {\n invalidateQueries: [['session']],\n },\n });\n};\n\nexport const useRefreshAccessKey = () => {\n const projectAPI = useProjectAPI();\n\n return useMutation({\n mutationKey: ['session', 'access-keys'],\n mutationFn: (args: RefreshAccessKeyBody) =>\n projectAPI.refreshAccessKey(args),\n meta: {\n invalidateQueries: [['session']],\n },\n });\n};\n\nexport const useUpdateMemberAccess = () => {\n const projectAPI = useProjectAPI();\n\n return useMutation({\n mutationKey: ['projects', 'member-access'],\n mutationFn: ({\n userId,\n ...body\n }: UpdateMemberAccessBody & { userId: string }) =>\n projectAPI.updateMemberAccess(userId, body),\n meta: {\n invalidateQueries: [['projects'], ['session']],\n },\n });\n};\n"],"mappings":";;;;;;;AAyBA,MAAa,kBACX,SACA,YACG;CACH,MAAM,aAAa,cAAc;CAEjC,OAAO,YAAY;EACjB,UAAU,CAAC,YAAY,OAAO;EAC9B,UAAU,EAAE,aAAa,WAAW,YAAY,SAAS,EAAE,OAAO,CAAC;EAEnE,aAAa;EACb,qBAAqB;EACrB,GAAG;CACL,CAAC;AACH;AAEA,MAAa,sBAAsB;CACjC,MAAM,aAAa,cAAc;CAEjC,OAAO,YAAY;EACjB,aAAa,CAAC,UAAU;EACxB,aAAa,SAAyB,WAAW,WAAW,IAAI;EAChE,MAAM,EACJ,mBAAmB,CAAC,CAAC,UAAU,CAAC,EAClC;CACF,CAAC;AACH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C/C;CACF,CAAC;AACH"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { useAuth } from "../useAuth/useAuth.mjs";
|
|
4
|
-
import { useQuery } from "@tanstack/react-query";
|
|
5
4
|
import { useConfiguration } from "@intlayer/editor-react";
|
|
5
|
+
import { useQuery } from "@tanstack/react-query";
|
|
6
6
|
|
|
7
7
|
//#region src/api/hooks/utils.ts
|
|
8
8
|
const useAuthEnable = ({ requireUser, requireProject, requireOrganization }) => {
|
package/dist/esm/api/index.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import { useGithubAuth, useGithubCheckConfig, useGithubGetAuthUrl, useGithubGetC
|
|
|
13
13
|
import { useGitlabAuth, useGitlabCheckConfig, useGitlabGetConfigFile, useGitlabProjects } from "./hooks/gitlab.mjs";
|
|
14
14
|
import { useGetNewsletterStatus, useSubscribeToNewsletter, useUnsubscribeFromNewsletter } from "./hooks/newsletter.mjs";
|
|
15
15
|
import { useAddOrganization, useAddOrganizationMember, useDeleteOrganization, useDeleteOrganizationById, useGetOrganizations, useSelectOrganization, useUnselectOrganization, useUpdateOrganization, useUpdateOrganizationMembers, useUpdateOrganizationMembersById } from "./hooks/organization.mjs";
|
|
16
|
-
import { useAddNewAccessKey, useAddProject, useDeleteAccessKey, useDeleteProject, useDeleteProjectById, useGetCIConfig, useGetProjects, usePushCIConfig, usePushProjectConfiguration, useRefreshAccessKey, useSelectProject, useTriggerBuild, useTriggerWebhook, useUnselectProject, useUpdateProject, useUpdateProjectMembers } from "./hooks/project.mjs";
|
|
16
|
+
import { useAddEnvironment, useAddNewAccessKey, useAddProject, useDeleteAccessKey, useDeleteEnvironment, useDeleteProject, useDeleteProjectById, useGetCIConfig, useGetProjects, useMigrateEnvironment, usePushCIConfig, usePushProjectConfiguration, useRefreshAccessKey, useResetToProductionEnvironment, useSelectEnvironment, useSelectProject, useTriggerBuild, useTriggerWebhook, useUnselectProject, useUpdateEnvironment, useUpdateMemberAccess, useUpdateProject, useUpdateProjectMembers } from "./hooks/project.mjs";
|
|
17
17
|
import { useContactReviewer, useCreateMission, useDeleteReviewerProfile, useEstimateMission, useGetAdminReviewers, useGetChatHistory, useGetMissionById, useGetMyMissions, useGetMyReviewerProfile, useGetReviewerById, useGetReviewerMarketplace, useGetReviewerPriceDistribution, useGetReviewerReviews, useRegisterAsReviewer, useSendReviewerMessage, useSubmitReview, useUpdateMissionStatus, useUpdateReviewerProfile, useUploadReviewerCoverPicture, useUploadReviewerMainPicture, useValidateReviewerProfile } from "./hooks/reviewer.mjs";
|
|
18
18
|
import { useSearchDoc } from "./hooks/search.mjs";
|
|
19
19
|
import { useDeleteShowcaseProject, useGetOtherShowcaseProjects, useGetShowcaseProjectById, useGetShowcaseProjects, useSubmitShowcaseProject, useToggleShowcaseDownvote, useToggleShowcaseUpvote, useUpdateShowcaseProject } from "./hooks/showcaseProject.mjs";
|
|
@@ -23,4 +23,4 @@ import { useFillAllTranslations, usePauseTranslationJob, useResumeTranslationJob
|
|
|
23
23
|
import { useCreateUser, useDeleteUser, useGetUserById, useGetUsers, useUpdateUser, useUploadUserAvatar } from "./hooks/user.mjs";
|
|
24
24
|
import { useUser } from "./useUser/index.mjs";
|
|
25
25
|
|
|
26
|
-
export { useAcceptAffiliateInvitation, useAddDictionary, useAddNewAccessKey, useAddOrganization, useAddOrganizationMember, useAddPasskey, useAddProject, useAddTag, useAiAPI, useAskDocQuestion, useAskResetPassword, useAuditAPI, useAuditContentDeclaration, useAuditContentDeclarationField, useAuditContentDeclarationMetadata, useAuditScan, useAuditTag, useAuth, useAutocomplete, useBitbucketAPI, useBitbucketAuth, useBitbucketCheckConfig, useBitbucketGetConfigFile, useBitbucketRepos, useCancelSubscription, useChangePassword, useChat, useContactReviewer, useCreateMission, useCreatePortalSession, useCreatePromoCode, useCreateUser, useDeleteAccessKey, useDeleteDictionary, useDeleteOrganization, useDeleteOrganizationById, useDeletePasskey, useDeleteProject, useDeleteProjectById, useDeletePromoCode, useDeleteReviewerProfile, useDeleteSSOProvider, useDeleteShowcaseProject, useDeleteTag, useDeleteUser, useDictionaryAPI, useDisableTwoFactor, useEditorAPI, useEnableTwoFactor, useEstimateMission, useFillAllTranslations, useGetAdminReviewers, useGetAffiliate, useGetAffiliateAccountSession, useGetAffiliateById, useGetAffiliateInvitation, useGetAffiliateInvitations, useGetAffiliateOnboardingLink, useGetAffiliatePromoCode, useGetAffiliateStats, useGetAffiliates, useGetCIConfig, useGetChatHistory, useGetDictionaries, useGetDictionariesKeys, useGetDictionary, useGetDiscussions, useGetDiscussionsData, useGetEditorDictionaries, useGetInvoices, useGetMissionById, useGetMyMissions, useGetMyReviewerProfile, useGetNewsletterStatus, useGetOrganizations, useGetOtherShowcaseProjects, useGetPaymentMethod, useGetPricing, useGetProjects, useGetPromoCodeById, useGetPromoCodes, useGetRecursiveAuditStatus, useGetReviewerById, useGetReviewerMarketplace, useGetReviewerPriceDistribution, useGetReviewerReviews, useGetShowcaseProjectById, useGetShowcaseProjects, useGetSubscription, useGetTags, useGetUserByAccount, useGetUserById, useGetUsers, useGetVerifyEmailStatus, useGithubAPI, useGithubAuth, useGithubCheckConfig, useGithubGetAuthUrl, useGithubGetConfigFile, useGithubRepos, useGithubToken, useGitlabAPI, useGitlabAuth, useGitlabCheckConfig, useGitlabGetConfigFile, useGitlabProjects, useGrantAffiliateAccess, useInfiniteGetDictionaries, useIntlayerAuth, useIntlayerOAuth, useIntlayerOAuthOptions, useLinkSocial, useListAccounts, useListPasskeys, useListSSOProviders, useLogin, useLogout, useNewsletterAPI, useOAuth2, useOAuthAPI, useOrganizationAPI, usePauseTranslationJob, useProjectAPI, usePushCIConfig, usePushDictionaries, usePushProjectConfiguration, useRefreshAccessKey, useRegister, useRegisterAsReviewer, useRegisterSSO, useResetPassword, useResumeTranslationJob, useReviewerAPI, useSearchAPI, useSearchDoc, useSelectOrganization, useSelectProject, useSendAffiliateInvitation, useSendReviewerMessage, useSession, useShowcaseProjectAPI, useSignInMagicLink, useSignInPasskey, useSignInSSO, useStartRecursiveAudit, useStopTranslationJob, useStripeAPI, useSubmitReview, useSubmitShowcaseProject, useSubscribeToNewsletter, useTagAPI, useToggleShowcaseDownvote, useToggleShowcaseUpvote, useTranslateAPI, useTranslateJSONDeclaration, useTriggerBuild, useTriggerWebhook, useUnlinkAccount, useUnselectOrganization, useUnselectProject, useUnsubscribeFromNewsletter, useUpdateAffiliateStatus, useUpdateDictionary, useUpdateMissionStatus, useUpdateOrganization, useUpdateOrganizationMembers, useUpdateOrganizationMembersById, useUpdateProject, useUpdateProjectMembers, useUpdatePromoCode, useUpdateReviewerProfile, useUpdateShowcaseProject, useUpdateTag, useUpdateUser, useUploadReviewerCoverPicture, useUploadReviewerMainPicture, useUploadUserAvatar, useUser, useUserAPI, useValidateReviewerProfile, useVerifyBackupCode, useVerifyEmail, useVerifyTotp, useWriteDictionary };
|
|
26
|
+
export { useAcceptAffiliateInvitation, useAddDictionary, useAddEnvironment, useAddNewAccessKey, useAddOrganization, useAddOrganizationMember, useAddPasskey, useAddProject, useAddTag, useAiAPI, useAskDocQuestion, useAskResetPassword, useAuditAPI, useAuditContentDeclaration, useAuditContentDeclarationField, useAuditContentDeclarationMetadata, useAuditScan, useAuditTag, useAuth, useAutocomplete, useBitbucketAPI, useBitbucketAuth, useBitbucketCheckConfig, useBitbucketGetConfigFile, useBitbucketRepos, useCancelSubscription, useChangePassword, useChat, useContactReviewer, useCreateMission, useCreatePortalSession, useCreatePromoCode, useCreateUser, useDeleteAccessKey, useDeleteDictionary, useDeleteEnvironment, useDeleteOrganization, useDeleteOrganizationById, useDeletePasskey, useDeleteProject, useDeleteProjectById, useDeletePromoCode, useDeleteReviewerProfile, useDeleteSSOProvider, useDeleteShowcaseProject, useDeleteTag, useDeleteUser, useDictionaryAPI, useDisableTwoFactor, useEditorAPI, useEnableTwoFactor, useEstimateMission, useFillAllTranslations, useGetAdminReviewers, useGetAffiliate, useGetAffiliateAccountSession, useGetAffiliateById, useGetAffiliateInvitation, useGetAffiliateInvitations, useGetAffiliateOnboardingLink, useGetAffiliatePromoCode, useGetAffiliateStats, useGetAffiliates, useGetCIConfig, useGetChatHistory, useGetDictionaries, useGetDictionariesKeys, useGetDictionary, useGetDiscussions, useGetDiscussionsData, useGetEditorDictionaries, useGetInvoices, useGetMissionById, useGetMyMissions, useGetMyReviewerProfile, useGetNewsletterStatus, useGetOrganizations, useGetOtherShowcaseProjects, useGetPaymentMethod, useGetPricing, useGetProjects, useGetPromoCodeById, useGetPromoCodes, useGetRecursiveAuditStatus, useGetReviewerById, useGetReviewerMarketplace, useGetReviewerPriceDistribution, useGetReviewerReviews, useGetShowcaseProjectById, useGetShowcaseProjects, useGetSubscription, useGetTags, useGetUserByAccount, useGetUserById, useGetUsers, useGetVerifyEmailStatus, useGithubAPI, useGithubAuth, useGithubCheckConfig, useGithubGetAuthUrl, useGithubGetConfigFile, useGithubRepos, useGithubToken, useGitlabAPI, useGitlabAuth, useGitlabCheckConfig, useGitlabGetConfigFile, useGitlabProjects, useGrantAffiliateAccess, useInfiniteGetDictionaries, useIntlayerAuth, useIntlayerOAuth, useIntlayerOAuthOptions, useLinkSocial, useListAccounts, useListPasskeys, useListSSOProviders, useLogin, useLogout, useMigrateEnvironment, useNewsletterAPI, useOAuth2, useOAuthAPI, useOrganizationAPI, usePauseTranslationJob, useProjectAPI, usePushCIConfig, usePushDictionaries, usePushProjectConfiguration, useRefreshAccessKey, useRegister, useRegisterAsReviewer, useRegisterSSO, useResetPassword, useResetToProductionEnvironment, useResumeTranslationJob, useReviewerAPI, useSearchAPI, useSearchDoc, useSelectEnvironment, useSelectOrganization, useSelectProject, useSendAffiliateInvitation, useSendReviewerMessage, useSession, useShowcaseProjectAPI, useSignInMagicLink, useSignInPasskey, useSignInSSO, useStartRecursiveAudit, useStopTranslationJob, useStripeAPI, useSubmitReview, useSubmitShowcaseProject, useSubscribeToNewsletter, useTagAPI, useToggleShowcaseDownvote, useToggleShowcaseUpvote, useTranslateAPI, useTranslateJSONDeclaration, useTriggerBuild, useTriggerWebhook, useUnlinkAccount, useUnselectOrganization, useUnselectProject, useUnsubscribeFromNewsletter, useUpdateAffiliateStatus, useUpdateDictionary, useUpdateEnvironment, useUpdateMemberAccess, useUpdateMissionStatus, useUpdateOrganization, useUpdateOrganizationMembers, useUpdateOrganizationMembersById, useUpdateProject, useUpdateProjectMembers, useUpdatePromoCode, useUpdateReviewerProfile, useUpdateShowcaseProject, useUpdateTag, useUpdateUser, useUploadReviewerCoverPicture, useUploadReviewerMainPicture, useUploadUserAvatar, useUser, useUserAPI, useValidateReviewerProfile, useVerifyBackupCode, useVerifyEmail, useVerifyTotp, useWriteDictionary };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { useQuery } from "@tanstack/react-query";
|
|
4
3
|
import { editor } from "@intlayer/config/built";
|
|
5
|
-
import { useConfiguration } from "@intlayer/editor-react";
|
|
6
4
|
import { getOAuthAPI } from "@intlayer/api";
|
|
5
|
+
import { useConfiguration } from "@intlayer/editor-react";
|
|
6
|
+
import { useQuery } from "@tanstack/react-query";
|
|
7
7
|
import { defu } from "defu";
|
|
8
8
|
|
|
9
9
|
//#region src/api/useAuth/useOAuth2.ts
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { getAuthAPI } from "../../libs/auth.mjs";
|
|
4
|
-
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
5
4
|
import { editor } from "@intlayer/config/built";
|
|
6
5
|
import { useConfiguration } from "@intlayer/editor-react";
|
|
6
|
+
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
7
7
|
|
|
8
8
|
//#region src/api/useAuth/useSession.ts
|
|
9
9
|
const useSession = (sessionProp, intlayerConfiguration) => {
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import { getAuthAPI } from "../libs/auth.mjs";
|
|
4
4
|
import { useAuth } from "./useAuth/useAuth.mjs";
|
|
5
|
-
import { useConfiguration } from "@intlayer/editor-react";
|
|
6
5
|
import { getIntlayerAPI } from "@intlayer/api";
|
|
7
6
|
import { getAiAPI } from "@intlayer/api/ai";
|
|
8
7
|
import { getAuditAPI } from "@intlayer/api/audit";
|
|
@@ -22,6 +21,7 @@ import { getStripeAPI } from "@intlayer/api/stripe";
|
|
|
22
21
|
import { getTagAPI } from "@intlayer/api/tag";
|
|
23
22
|
import { getTranslateAPI } from "@intlayer/api/translate";
|
|
24
23
|
import { getUserAPI } from "@intlayer/api/user";
|
|
24
|
+
import { useConfiguration } from "@intlayer/editor-react";
|
|
25
25
|
|
|
26
26
|
//#region src/api/useIntlayerAPI.ts
|
|
27
27
|
const useIntlayerOAuthOptions = (props) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.mjs","names":[],"sources":["../../../../src/components/Accordion/Accordion.tsx"],"sourcesContent":["'use client';\n\nimport { cn } from '@utils/cn';\nimport { ChevronDown } from 'lucide-react';\nimport {\n type FC,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n useId,\n useState,\n} from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"Accordion.mjs","names":[],"sources":["../../../../src/components/Accordion/Accordion.tsx"],"sourcesContent":["'use client';\n\nimport { cn } from '@utils/cn';\nimport { ChevronDown } from 'lucide-react';\nimport {\n type FC,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n useId,\n useState,\n} from 'react';\nimport { Button, type ButtonProps } from '../Button';\nimport { MaxHeightSmoother } from '../MaxHeightSmoother';\n\nexport interface AccordionProps\n extends Omit<ButtonProps, 'children' | 'onToggle'> {\n /** The content displayed in the accordion header */\n header: ReactNode;\n /** The collapsible content inside the accordion */\n children: ReactNode;\n /** Controls whether the accordion is open (controlled mode) */\n isOpen?: boolean;\n /** Default open state (uncontrolled mode) */\n defaultIsOpen?: boolean;\n /** Called when the accordion state changes */\n onToggle?: (isOpen: boolean) => void;\n /** Disable the accordion interaction */\n disabled?: boolean;\n /** Custom class for the content container */\n contentClassName?: string;\n /** Custom class for the header container */\n headerClassName?: string;\n /** Accessible label for screen readers */\n 'aria-label'?: string;\n /** ID for the accordion content (for aria-controls) */\n contentId?: string;\n}\n\n/**\n * Accordion component that allows the user to expand and collapse content.\n * It provides a header with a chevron icon that controls the visibility of the content.\n *\n * Features:\n * - Supports both controlled and uncontrolled modes\n * - Accessible with proper ARIA attributes\n * - Keyboard navigation support\n * - Smooth animations for expand/collapse\n * - Customizable styling\n *\n * @param header - The content of the header.\n * @param children - The content to be expanded and collapsed.\n * @param isOpen - Controlled state for whether the content is expanded.\n * @param defaultIsOpen - Default open state for uncontrolled mode.\n * @param onToggle - Callback when the accordion state changes.\n * @param disabled - Whether the accordion is disabled.\n * @param contentClassName - Custom class for the content container.\n * @param headerClassName - Custom class for the header.\n * @param contentId - ID for the content (used for aria-controls).\n *\n * @example\n * // Uncontrolled mode\n * <Accordion header=\"Accordion Header\" defaultIsOpen={true}>\n * <p>Accordion content</p>\n * </Accordion>\n *\n * @example\n * // Controlled mode\n * <Accordion\n * header=\"Controlled Accordion\"\n * isOpen={isOpen}\n * onToggle={setIsOpen}\n * >\n * <p>Controlled content</p>\n * </Accordion>\n */\nexport const Accordion: FC<AccordionProps> = ({\n children,\n header,\n isOpen,\n defaultIsOpen = false,\n onToggle,\n onClick,\n disabled = false,\n contentClassName,\n headerClassName,\n contentId,\n 'aria-label': ariaLabel,\n ...props\n}) => {\n // Determine if we're in controlled or uncontrolled mode\n const isControlled = isOpen !== undefined;\n const [internalIsOpen, setInternalIsOpen] = useState(defaultIsOpen);\n const id = useId();\n\n // Use controlled value if provided, otherwise use internal state\n const isExpandedState = isControlled ? isOpen : internalIsOpen;\n const isHidden = !isExpandedState;\n\n // Generate unique ID for content if not provided\n const generatedContentId = contentId ?? `${id}-accordion-content`;\n\n const handleToggle = (e: MouseEvent<HTMLButtonElement>) => {\n if (disabled) return;\n\n const newIsOpen = !isExpandedState;\n\n // Update internal state if uncontrolled\n if (!isControlled) {\n setInternalIsOpen(newIsOpen);\n }\n\n // Call external handlers\n onToggle?.(newIsOpen);\n onClick?.(e);\n };\n\n const handleKeyDown = (e: KeyboardEvent<HTMLButtonElement>) => {\n // Enter and Space should toggle the accordion\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n handleToggle(e as any);\n }\n };\n\n return (\n <div className=\"w-full\">\n <Button\n variant=\"hoverable\"\n color=\"text\"\n onClick={handleToggle}\n onKeyDown={handleKeyDown}\n disabled={disabled}\n isFullWidth\n className={cn(\n 'flex items-center justify-between gap-2',\n headerClassName\n )}\n IconRight={ChevronDown}\n iconClassName={cn(\n 'transform transition-transform duration-500 ease-in-out',\n isExpandedState ? 'rotate-0' : '-rotate-180'\n )}\n aria-expanded={isExpandedState}\n aria-controls={generatedContentId}\n aria-label={ariaLabel}\n role=\"button\"\n {...props}\n >\n {header}\n </Button>\n\n <MaxHeightSmoother\n id={generatedContentId}\n tabIndex={isHidden ? -1 : undefined}\n isHidden={isHidden}\n className={contentClassName}\n role=\"region\"\n aria-labelledby={generatedContentId}\n >\n {children}\n </MaxHeightSmoother>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4EA,MAAa,aAAiC,EAC5C,UACA,QACA,QACA,gBAAgB,OAChB,UACA,SACA,WAAW,OACX,kBACA,iBACA,WACA,cAAc,WACd,GAAG,YACC;CAEJ,MAAM,eAAe,WAAW;CAChC,MAAM,CAAC,gBAAgB,qBAAqB,SAAS,aAAa;CAClE,MAAM,KAAK,MAAM;CAGjB,MAAM,kBAAkB,eAAe,SAAS;CAChD,MAAM,WAAW,CAAC;CAGlB,MAAM,qBAAqB,aAAa,GAAG,GAAG;CAE9C,MAAM,gBAAgB,MAAqC;EACzD,IAAI,UAAU;EAEd,MAAM,YAAY,CAAC;EAGnB,IAAI,CAAC,cACH,kBAAkB,SAAS;EAI7B,WAAW,SAAS;EACpB,UAAU,CAAC;CACb;CAEA,MAAM,iBAAiB,MAAwC;EAE7D,IAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK;GACtC,EAAE,eAAe;GACjB,aAAa,CAAQ;EACvB;CACF;CAEA,OACE,qBAAC,OAAD;EAAK,WAAU;YAAf,CACE,oBAAC,QAAD;GACE,SAAQ;GACR,OAAM;GACN,SAAS;GACT,WAAW;GACD;GACV;GACA,WAAW,GACT,2CACA,eACF;GACA,WAAW;GACX,eAAe,GACb,2DACA,kBAAkB,aAAa,aACjC;GACA,iBAAe;GACf,iBAAe;GACf,cAAY;GACZ,MAAK;GACL,GAAI;aAEH;EACK,IAER,oBAAC,mBAAD;GACE,IAAI;GACJ,UAAU,WAAW,KAAK;GAChB;GACV,WAAW;GACX,MAAK;GACL,mBAAiB;GAEhB;EACgB,EAChB;;AAET"}
|
|
@@ -4,69 +4,32 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
4
4
|
|
|
5
5
|
//#region src/components/Badge/index.tsx
|
|
6
6
|
/**
|
|
7
|
-
* Badge color variants enum
|
|
8
|
-
* @description Defines the available color themes for the badge component
|
|
9
|
-
*/
|
|
10
|
-
let BadgeColor = /* @__PURE__ */ function(BadgeColor) {
|
|
11
|
-
BadgeColor["PRIMARY"] = "primary";
|
|
12
|
-
BadgeColor["SECONDARY"] = "secondary";
|
|
13
|
-
BadgeColor["SUCCESS"] = "success";
|
|
14
|
-
BadgeColor["ERROR"] = "error";
|
|
15
|
-
BadgeColor["NEUTRAL"] = "neutral";
|
|
16
|
-
BadgeColor["LIGHT"] = "light";
|
|
17
|
-
BadgeColor["DARK"] = "dark";
|
|
18
|
-
BadgeColor["TEXT"] = "text";
|
|
19
|
-
BadgeColor["CUSTOM"] = "custom";
|
|
20
|
-
return BadgeColor;
|
|
21
|
-
}({});
|
|
22
|
-
/**
|
|
23
|
-
* Badge visual variants enum
|
|
24
|
-
* @description Defines the available visual styles for the badge component
|
|
25
|
-
*/
|
|
26
|
-
let BadgeVariant = /* @__PURE__ */ function(BadgeVariant) {
|
|
27
|
-
BadgeVariant["DEFAULT"] = "default";
|
|
28
|
-
BadgeVariant["NONE"] = "none";
|
|
29
|
-
BadgeVariant["OUTLINE"] = "outline";
|
|
30
|
-
BadgeVariant["HOVERABLE"] = "hoverable";
|
|
31
|
-
return BadgeVariant;
|
|
32
|
-
}({});
|
|
33
|
-
/**
|
|
34
|
-
* Badge size variants enum
|
|
35
|
-
* @description Defines the available sizes for the badge component
|
|
36
|
-
*/
|
|
37
|
-
let BadgeSize = /* @__PURE__ */ function(BadgeSize) {
|
|
38
|
-
BadgeSize["SMALL"] = "sm";
|
|
39
|
-
BadgeSize["MEDIUM"] = "md";
|
|
40
|
-
BadgeSize["LARGE"] = "lg";
|
|
41
|
-
return BadgeSize;
|
|
42
|
-
}({});
|
|
43
|
-
/**
|
|
44
7
|
* Badge component variants using class-variance-authority
|
|
45
8
|
* @description Defines the styling variants for different badge combinations
|
|
46
9
|
*/
|
|
47
10
|
const badgeVariants = cva("inline-flex items-center rounded-md border px-2.5 py-0.5 font-semibold text-xs transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2", {
|
|
48
11
|
variants: {
|
|
49
12
|
color: {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
13
|
+
primary: "border-primary bg-primary text-primary hover:bg-primary-500",
|
|
14
|
+
secondary: "border-secondary bg-secondary text-secondary hover:bg-secondary-300",
|
|
15
|
+
success: "border-success bg-success text-success hover:bg-success-500",
|
|
16
|
+
error: "border-error bg-error text-error hover:bg-error-500",
|
|
17
|
+
neutral: "border-neutral bg-neutral text-neutral hover:bg-neutral-600",
|
|
18
|
+
light: "border-white bg-white text-white hover:bg-neutral-500",
|
|
19
|
+
dark: "border-neutral-800 bg-neutral-800 text-neutral-800 hover:bg-neutral-900",
|
|
20
|
+
text: "border-text bg-text text-text hover:opacity-80",
|
|
21
|
+
custom: ""
|
|
59
22
|
},
|
|
60
23
|
variant: {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
24
|
+
default: "rounded-lg text-text-opposite",
|
|
25
|
+
none: "border-none bg-opacity-0 text-inherit hover:bg-opacity-0",
|
|
26
|
+
outline: "rounded-lg border-[1.3px] bg-opacity-0 hover:bg-opacity-30",
|
|
27
|
+
hoverable: "rounded-lg border-none bg-opacity-0 transition hover:bg-opacity-10"
|
|
65
28
|
},
|
|
66
29
|
size: {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
30
|
+
sm: "px-2 py-0.5 text-xs",
|
|
31
|
+
md: "px-2.5 py-0.5 text-xs",
|
|
32
|
+
lg: "px-3 py-1 text-sm"
|
|
70
33
|
}
|
|
71
34
|
},
|
|
72
35
|
defaultVariants: {
|
|
@@ -87,7 +50,7 @@ const badgeVariants = cva("inline-flex items-center rounded-md border px-2.5 py-
|
|
|
87
50
|
* <Badge>New</Badge>
|
|
88
51
|
*
|
|
89
52
|
* // Colored badge
|
|
90
|
-
* <Badge color=
|
|
53
|
+
* <Badge color="error">Error</Badge>
|
|
91
54
|
*
|
|
92
55
|
* // Clickable badge
|
|
93
56
|
* <Badge clickable onClick={() => console.log('clicked')}>
|
|
@@ -145,5 +108,5 @@ const Badge = ({ className, variant = "default", color = "primary", size = "md",
|
|
|
145
108
|
};
|
|
146
109
|
|
|
147
110
|
//#endregion
|
|
148
|
-
export { Badge,
|
|
111
|
+
export { Badge, badgeVariants };
|
|
149
112
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/components/Badge/index.tsx"],"sourcesContent":["import { cn } from '@utils/cn';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport type { HTMLAttributes } from 'react';\n\n/**\n * Badge color variants enum\n * @description Defines the available color themes for the badge component\n */\nexport
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/components/Badge/index.tsx"],"sourcesContent":["import { cn } from '@utils/cn';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport type { HTMLAttributes } from 'react';\n\n/**\n * Badge color variants enum\n * @description Defines the available color themes for the badge component\n */\nexport type BadgeColor =\n | 'primary'\n | 'secondary'\n | 'success'\n | 'error'\n | 'neutral'\n | 'light'\n | 'dark'\n | 'text'\n | 'custom';\n\n/**\n * Badge visual variants enum\n * @description Defines the available visual styles for the badge component\n */\nexport type BadgeVariant = 'default' | 'none' | 'outline' | 'hoverable';\n\n/**\n * Badge size variants enum\n * @description Defines the available sizes for the badge component\n */\nexport type BadgeSize = 'sm' | 'md' | 'lg';\n\n/**\n * Badge component variants using class-variance-authority\n * @description Defines the styling variants for different badge combinations\n */\nexport const badgeVariants = cva(\n 'inline-flex items-center rounded-md border px-2.5 py-0.5 font-semibold text-xs transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2',\n {\n variants: {\n color: {\n primary: 'border-primary bg-primary text-primary hover:bg-primary-500',\n secondary:\n 'border-secondary bg-secondary text-secondary hover:bg-secondary-300',\n success: 'border-success bg-success text-success hover:bg-success-500',\n error: 'border-error bg-error text-error hover:bg-error-500',\n neutral: 'border-neutral bg-neutral text-neutral hover:bg-neutral-600',\n light: 'border-white bg-white text-white hover:bg-neutral-500',\n dark: 'border-neutral-800 bg-neutral-800 text-neutral-800 hover:bg-neutral-900',\n text: 'border-text bg-text text-text hover:opacity-80',\n custom: '',\n },\n variant: {\n default: 'rounded-lg text-text-opposite',\n none: 'border-none bg-opacity-0 text-inherit hover:bg-opacity-0',\n outline: 'rounded-lg border-[1.3px] bg-opacity-0 hover:bg-opacity-30',\n hoverable:\n 'rounded-lg border-none bg-opacity-0 transition hover:bg-opacity-10',\n },\n size: {\n sm: 'px-2 py-0.5 text-xs',\n md: 'px-2.5 py-0.5 text-xs',\n lg: 'px-3 py-1 text-sm',\n },\n },\n defaultVariants: {\n variant: 'default',\n color: 'primary',\n size: 'md',\n },\n }\n);\n\n/**\n * Badge component props interface\n * @description Comprehensive props for the Badge component with accessibility and interactive features\n */\nexport type BadgeProps = HTMLAttributes<HTMLElement> & {\n /** The content to display inside the badge */\n children?: React.ReactNode;\n /** Color theme variant */\n color?: BadgeColor | `${BadgeColor}`;\n /** Visual style variant */\n variant?: BadgeVariant | `${BadgeVariant}`;\n /** Size of the badge */\n size?: BadgeSize | `${BadgeSize}`;\n /** Whether the badge is clickable */\n clickable?: boolean;\n /** Whether the badge is dismissible (shows close button) */\n dismissible?: boolean;\n /** Click handler for the badge */\n onClick?: (event: React.MouseEvent<HTMLElement>) => void;\n /** Click handler for the dismiss button */\n onDismiss?: () => void;\n /** ARIA label for accessibility */\n 'aria-label'?: string;\n /** Badge role for accessibility (default: 'status') */\n role?: 'status' | 'button' | 'generic';\n /** Whether badge should be focusable */\n tabIndex?: number;\n};\n\n/**\n * Utility type for badge variant props\n */\nexport type BadgeVariantProps = VariantProps<typeof badgeVariants>;\n\n/**\n * Badge component for displaying status indicators, labels, and notifications\n *\n * @description A flexible badge component that supports multiple visual styles, colors, and interactive features.\n * It maintains accessibility standards and provides comprehensive customization options.\n *\n * @example\n * ```tsx\n * // Basic badge\n * <Badge>New</Badge>\n *\n * // Colored badge\n * <Badge color=\"error\">Error</Badge>\n *\n * // Clickable badge\n * <Badge clickable onClick={() => console.log('clicked')}>\n * Clickable\n * </Badge>\n *\n * // Dismissible badge\n * <Badge dismissible onDismiss={() => console.log('dismissed')}>\n * Dismissible\n * </Badge>\n * ```\n */\nexport const Badge: React.FC<BadgeProps> = ({\n className,\n variant = 'default',\n color = 'primary',\n size = 'md',\n children,\n clickable = false,\n dismissible = false,\n onClick,\n onDismiss,\n role,\n tabIndex,\n 'aria-label': ariaLabel,\n ...props\n}) => {\n const Component = clickable ? 'button' : 'span';\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (clickable && onClick && (event.key === 'Enter' || event.key === ' ')) {\n event.preventDefault();\n onClick(event as any);\n }\n };\n\n const handleDismiss = (event: React.MouseEvent) => {\n event.stopPropagation();\n onDismiss?.();\n };\n\n return (\n <Component\n className={cn(\n badgeVariants({ variant, color, size }),\n clickable &&\n 'cursor-pointer hover:opacity-80 focus-visible:ring-2 focus-visible:ring-offset-2',\n dismissible && 'pr-1',\n className\n )}\n onClick={clickable ? onClick : undefined}\n onKeyDown={clickable ? handleKeyDown : undefined}\n role={role || (clickable ? 'button' : 'status')}\n tabIndex={clickable ? (tabIndex ?? 0) : tabIndex}\n aria-label={ariaLabel || (clickable ? `${children} button` : undefined)}\n {...props}\n >\n {children}\n {dismissible && (\n <button\n type=\"button\"\n className=\"ml-1 inline-flex h-4 w-4 items-center justify-center rounded-full hover:bg-black/10 focus:outline-none focus:ring-1 focus:ring-offset-1\"\n onClick={handleDismiss}\n aria-label={`Remove ${children} badge`}\n >\n <svg\n className=\"size-3\"\n viewBox=\"0 0 20 20\"\n fill=\"currentColor\"\n aria-label=\"Remove badge\"\n >\n <title>Remove badge</title>\n <path\n fillRule=\"evenodd\"\n d=\"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z\"\n clipRule=\"evenodd\"\n />\n </svg>\n </button>\n )}\n </Component>\n );\n};\n"],"mappings":";;;;;;;;;AAmCA,MAAa,gBAAgB,IAC3B,0KACA;CACE,UAAU;EACR,OAAO;GACL,SAAS;GACT,WACE;GACF,SAAS;GACT,OAAO;GACP,SAAS;GACT,OAAO;GACP,MAAM;GACN,MAAM;GACN,QAAQ;EACV;EACA,SAAS;GACP,SAAS;GACT,MAAM;GACN,SAAS;GACT,WACE;EACJ;EACA,MAAM;GACJ,IAAI;GACJ,IAAI;GACJ,IAAI;EACN;CACF;CACA,iBAAiB;EACf,SAAS;EACT,OAAO;EACP,MAAM;CACR;AACF,CACF;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,MAAa,SAA+B,EAC1C,WACA,UAAU,WACV,QAAQ,WACR,OAAO,MACP,UACA,YAAY,OACZ,cAAc,OACd,SACA,WACA,MACA,UACA,cAAc,WACd,GAAG,YACC;CACJ,MAAM,YAAY,YAAY,WAAW;CAEzC,MAAM,iBAAiB,UAA4C;EACjE,IAAI,aAAa,YAAY,MAAM,QAAQ,WAAW,MAAM,QAAQ,MAAM;GACxE,MAAM,eAAe;GACrB,QAAQ,KAAY;EACtB;CACF;CAEA,MAAM,iBAAiB,UAA4B;EACjD,MAAM,gBAAgB;EACtB,YAAY;CACd;CAEA,OACE,qBAAC,WAAD;EACE,WAAW,GACT,cAAc;GAAE;GAAS;GAAO;EAAK,CAAC,GACtC,aACE,oFACF,eAAe,QACf,SACF;EACA,SAAS,YAAY,UAAU;EAC/B,WAAW,YAAY,gBAAgB;EACvC,MAAM,SAAS,YAAY,WAAW;EACtC,UAAU,YAAa,YAAY,IAAK;EACxC,cAAY,cAAc,YAAY,GAAG,SAAS,WAAW;EAC7D,GAAI;YAbN,CAeG,UACA,eACC,oBAAC,UAAD;GACE,MAAK;GACL,WAAU;GACV,SAAS;GACT,cAAY,UAAU,SAAS;aAE/B,qBAAC,OAAD;IACE,WAAU;IACV,SAAQ;IACR,MAAK;IACL,cAAW;cAJb,CAME,oBAAC,SAAD,YAAO,eAAmB,IAC1B,oBAAC,QAAD;KACE,UAAS;KACT,GAAE;KACF,UAAS;IACV,EACE;;EACC,EAED;;AAEf"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { cn } from "../../utils/cn.mjs";
|
|
4
|
-
import { Button
|
|
5
|
-
import { Link
|
|
4
|
+
import { Button } from "../Button/Button.mjs";
|
|
5
|
+
import { Link } from "../Link/Link.mjs";
|
|
6
6
|
import { Fragment, createElement } from "react";
|
|
7
7
|
import { cva } from "class-variance-authority";
|
|
8
8
|
import { ChevronRightIcon } from "lucide-react";
|
|
@@ -17,16 +17,16 @@ import { useIntlayer } from "react-intlayer";
|
|
|
17
17
|
const getColorClass = (color) => {
|
|
18
18
|
if (!color) return "";
|
|
19
19
|
return {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
primary: "text-primary",
|
|
21
|
+
secondary: "text-secondary",
|
|
22
|
+
neutral: "text-neutral",
|
|
23
|
+
light: "text-white",
|
|
24
|
+
dark: "text-neutral-800",
|
|
25
|
+
text: "text-text",
|
|
26
|
+
"text-inverse": "text-text-opposite",
|
|
27
|
+
error: "text-error",
|
|
28
|
+
success: "text-success",
|
|
29
|
+
custom: ""
|
|
30
30
|
}[color] || "";
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/components/Breadcrumb/index.tsx"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { cn } from '@utils/cn';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { getIntlayer } from 'intlayer';\nimport { ChevronRightIcon } from 'lucide-react';\nimport { type FC, Fragment, type HTMLAttributes, type ReactNode } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { Button, type ButtonProps, ButtonVariant } from '../Button';\nimport { Link, LinkColor } from '../Link';\n\n/**\n * Props for LinkLink sub-component that renders breadcrumb items as links\n */\ntype LinkLinkProps = {\n /**\n * Position of the breadcrumb item in the list (1-based index)\n */\n position: number;\n /**\n * Locale for internationalization\n */\n locale?: LocalesValues;\n /**\n * URL to navigate to\n */\n href?: string;\n /**\n * Link color\n */\n color?: LinkColor | `${LinkColor}`;\n /**\n * Click handler\n */\n onClick?: () => void;\n /**\n * Children content\n */\n children?: string;\n /**\n * Additional CSS classes\n */\n className?: string;\n} & Omit<\n HTMLAttributes<HTMLAnchorElement>,\n 'href' | 'onClick' | 'color' | 'children' | 'className'\n>;\n\n/**\n * Maps LinkColor to corresponding Tailwind text color classes\n */\nconst getColorClass = (color?: LinkColor | `${LinkColor}`): string => {\n if (!color) return '';\n\n const colorMap: Record<LinkColor, string> = {\n [LinkColor.PRIMARY]: 'text-primary',\n [LinkColor.SECONDARY]: 'text-secondary',\n [LinkColor.NEUTRAL]: 'text-neutral',\n [LinkColor.LIGHT]: 'text-white',\n [LinkColor.DARK]: 'text-neutral-800',\n [LinkColor.TEXT]: 'text-text',\n [LinkColor.TEXT_INVERSE]: 'text-text-opposite',\n [LinkColor.ERROR]: 'text-error',\n [LinkColor.SUCCESS]: 'text-success',\n [LinkColor.CUSTOM]: '',\n };\n\n return colorMap[color as LinkColor] || '';\n};\n\n/**\n * Breadcrumb variant styles using class-variance-authority\n */\nconst breadcrumbVariants = cva('flex flex-row flex-wrap items-center text-sm', {\n variants: {\n size: {\n small: 'gap-1 text-xs',\n medium: 'gap-2 text-sm',\n large: 'gap-3 text-base',\n },\n spacing: {\n compact: 'gap-1',\n normal: 'gap-2',\n loose: 'gap-4',\n },\n },\n defaultVariants: {\n size: 'medium',\n spacing: 'normal',\n },\n});\n\n/**\n * LinkLink sub-component for breadcrumb items that navigate to other pages\n */\nconst LinkLink: FC<LinkLinkProps> = ({\n href,\n lang,\n children,\n onClick,\n color,\n position,\n locale,\n className,\n ...props\n}) => {\n const content = getIntlayer('breadcrumb');\n const linkLabel = content.linkLabel;\n\n return (\n <>\n <Link\n href={href}\n locale={locale}\n color={color}\n onClick={onClick}\n itemProp=\"item\"\n isExternalLink={false}\n itemScope\n itemType=\"https://schema.org/WebPage\"\n {...props}\n label={`${linkLabel} ${children}`}\n itemID={href}\n size=\"sm\"\n >\n <span itemProp=\"name\">{children}</span>\n </Link>\n <meta itemProp=\"position\" content={position.toString()} />\n </>\n );\n};\n\n/**\n * Props for ButtonLink sub-component that renders breadcrumb items as interactive buttons\n */\ntype ButtonButtonProps = {\n /**\n * Text content for the breadcrumb button\n */\n children: string;\n /**\n * Position of the breadcrumb item in the list (1-based index)\n */\n position: number;\n} & Omit<ButtonProps, 'children' | 'label'>;\n\n/**\n * ButtonLink sub-component for breadcrumb items with click handlers\n */\nconst ButtonLink: FC<ButtonButtonProps> = ({\n children: text,\n onClick,\n color,\n position,\n className,\n ...props\n}) => {\n const { linkLabel } = useIntlayer('breadcrumb');\n\n return (\n <>\n <Button\n onClick={onClick}\n variant={ButtonVariant.LINK}\n label={`${linkLabel} ${text}`}\n color={color}\n itemProp=\"item\"\n {...props}\n >\n <span itemProp=\"name\">{text}</span>\n </Button>\n <meta itemProp=\"position\" content={position.toString()} />\n </>\n );\n};\n\n/**\n * Props for Span sub-component that renders static breadcrumb text\n */\ntype SpanProps = {\n /**\n * Text content for the static breadcrumb item\n */\n children: string;\n /**\n * Position of the breadcrumb item in the list (1-based index)\n */\n position: number;\n} & HTMLAttributes<HTMLSpanElement>;\n\n/**\n * Span sub-component for static breadcrumb text items\n */\nconst Span: FC<SpanProps> = ({ children, position, className, ...props }) => (\n <span\n itemProp=\"item\"\n className={cn(\n 'inline-flex items-center',\n 'font-medium text-neutral-700',\n 'transition-colors duration-200',\n className\n )}\n >\n <span itemProp=\"name\" {...props}>\n {children}\n </span>\n <meta itemProp=\"position\" content={position.toString()} />\n </span>\n);\n\n/**\n * Detailed breadcrumb link configuration with optional href or onClick\n */\ntype DetailedBreadcrumbLink = {\n /**\n * URL to navigate to when the breadcrumb item is clicked\n */\n href?: string;\n /**\n * Text content to display for this breadcrumb item\n */\n text: string;\n /**\n * Custom click handler function for interactive breadcrumb items\n */\n onClick?: () => void;\n};\n\n/**\n * Union type representing different breadcrumb item configurations:\n * - string: Simple text breadcrumb item\n * - DetailedBreadcrumbLink: Object with href, text, and/or onClick properties\n */\nexport type BreadcrumbLink = string | DetailedBreadcrumbLink;\n\nexport type BreadcrumbProps = {\n /**\n * Array of breadcrumb items\n */\n links: BreadcrumbLink[];\n /**\n * Color scheme for breadcrumb links\n * @default LinkColor.TEXT\n */\n color?: LinkColor | `${LinkColor}`;\n /**\n * Locale for internationalization\n */\n locale?: LocalesValues;\n /**\n * Element type for ARIA current attribute\n * @default 'page'\n */\n elementType?: 'page' | 'location';\n /**\n * Custom separator between breadcrumb items\n * @default ChevronRightIcon\n */\n separator?: ReactNode;\n /**\n * ARIA label for breadcrumb navigation\n * @default 'breadcrumb'\n */\n ariaLabel?: string;\n /**\n * Whether to include structured data markup\n * @default true\n */\n includeStructuredData?: boolean;\n /**\n * Maximum number of breadcrumb items to show before truncation\n */\n maxItems?: number;\n} & VariantProps<typeof breadcrumbVariants> &\n HTMLAttributes<HTMLOListElement>;\n\n/**\n * Breadcrumb component providing navigational context with accessibility features\n *\n * Features:\n * - Supports links, buttons, and static text elements\n * - Full keyboard navigation support\n * - ARIA attributes for screen readers\n * - Schema.org structured data for SEO\n * - Customizable separators and styling\n * - Internationalization support\n * - Responsive design variants\n *\n * @example\n * ```tsx\n * <Breadcrumb\n * links={[\n * 'Home',\n * { href: '/products', text: 'Products' },\n * { onClick: handleCategory, text: 'Electronics' },\n * 'Smartphones'\n * ]}\n * size=\"medium\"\n * ariaLabel=\"Product navigation\"\n * />\n * ```\n */\nexport const Breadcrumb: FC<BreadcrumbProps> = ({\n links,\n className,\n color = LinkColor.TEXT,\n locale,\n elementType = 'page',\n separator = <ChevronRightIcon size={10} />,\n ariaLabel = 'breadcrumb',\n includeStructuredData = true,\n maxItems,\n size,\n spacing,\n ...props\n}) => {\n const displayLinks =\n maxItems && links.length > maxItems\n ? [...links.slice(0, 1), '...', ...links.slice(-(maxItems - 2))]\n : links;\n\n return (\n <nav aria-label={ariaLabel}>\n <ol\n className={cn(breadcrumbVariants({ size, spacing }), className)}\n {...(includeStructuredData && {\n itemScope: true,\n itemType: 'http://schema.org/BreadcrumbList',\n })}\n {...props}\n >\n {displayLinks.map((link, index) => {\n const isLastLink = index === displayLinks.length - 1;\n const isLink =\n typeof link === 'object' && typeof link.href === 'string';\n const isButton =\n typeof link === 'object' && typeof link.onClick === 'function';\n const isActive = index === displayLinks.length - 1;\n const ariaCurrent = isActive ? elementType : undefined;\n const isTruncated = link === '...';\n\n const text = (link as DetailedBreadcrumbLink).text ?? link;\n\n const separatorColorClass = getColorClass(color);\n\n if (isTruncated) {\n return (\n <Fragment key={`truncated-${text}`}>\n <li className=\"flex items-center\" aria-hidden=\"true\">\n <span className=\"text-neutral-500\">…</span>\n </li>\n {!isLastLink && (\n <li aria-hidden=\"true\" className=\"flex items-center\">\n <span className={cn(separatorColorClass)}>{separator}</span>\n </li>\n )}\n </Fragment>\n );\n }\n\n let section = (\n <Span\n key={text}\n position={index + 1}\n aria-current={ariaCurrent}\n className={cn(\n 'transition-colors duration-200',\n isActive && 'text-neutral-900'\n )}\n >\n {text}\n </Span>\n );\n\n if (isLink) {\n section = (\n <LinkLink\n key={text}\n href={link.href!}\n color={color}\n position={index + 1}\n locale={locale}\n aria-current={ariaCurrent}\n className={cn(isActive && 'cursor-default text-neutral-900')}\n >\n {text}\n </LinkLink>\n );\n } else if (isButton) {\n section = (\n <ButtonLink\n key={text}\n onClick={link.onClick!}\n color={color}\n position={index + 1}\n aria-current={ariaCurrent}\n className={cn(isActive && 'cursor-default text-neutral-900')}\n >\n {text}\n </ButtonLink>\n );\n }\n\n const listElement = (\n <li\n {...(includeStructuredData && {\n itemProp: 'itemListElement',\n itemScope: true,\n itemType: 'https://schema.org/ListItem',\n })}\n key={text}\n className=\"flex items-center\"\n >\n {section}\n </li>\n );\n\n if (isLastLink) {\n return listElement;\n }\n\n return (\n <Fragment key={text}>\n {listElement}\n <li aria-hidden=\"true\" className=\"flex items-center\">\n <span className={cn(separatorColorClass)}>{separator}</span>\n </li>\n </Fragment>\n );\n })}\n </ol>\n </nav>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAoDA,MAAM,iBAAiB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AAU,QAAQ;KAClB,gBAAc;KACd,WAAW,GACT,kCACA,YAAY,kBACd;eAEC;IACG,GATC,IASD;IAGR,IAAI,QACF,UACE,oBAAC,UAAD;KAEE,MAAM,KAAK;KACJ;KACP,UAAU,QAAQ;KACV;KACR,gBAAc;KACd,WAAW,GAAG,YAAY,iCAAiC;eAE1D;IACO,GATH,IASG;SAEP,IAAI,UACT,UACE,oBAAC,YAAD;KAEE,SAAS,KAAK;KACP;KACP,UAAU,QAAQ;KAClB,gBAAc;KACd,WAAW,GAAG,YAAY,iCAAiC;eAE1D;IACS,GARL,IAQK;IAIhB,MAAM,cACJ,8BAAC,MAAD;KACE,GAAK,yBAAyB;MAC5B,UAAU;MACV,WAAW;MACX,UAAU;KACZ;KACA,KAAK;KACL,WAAU;IAGR,GADD,OACC;IAGN,IAAI,YACF,OAAO;IAGT,OACE,qBAAC,UAAD,aACG,aACD,oBAAC,MAAD;KAAI,eAAY;KAAO,WAAU;eAC/B,oBAAC,QAAD;MAAM,WAAW,GAAG,mBAAmB;gBAAI;KAAgB;IACzD,EACI,KALK,IAKL;GAEd,CAAC;EACC;CACD;AAET"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/components/Breadcrumb/index.tsx"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { cn } from '@utils/cn';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { getIntlayer } from 'intlayer';\nimport { ChevronRightIcon } from 'lucide-react';\nimport { type FC, Fragment, type HTMLAttributes, type ReactNode } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { Button, type ButtonProps } from '../Button';\nimport { Link, type LinkColor } from '../Link';\n\n/**\n * Props for LinkLink sub-component that renders breadcrumb items as links\n */\ntype LinkLinkProps = {\n /**\n * Position of the breadcrumb item in the list (1-based index)\n */\n position: number;\n /**\n * Locale for internationalization\n */\n locale?: LocalesValues;\n /**\n * URL to navigate to\n */\n href?: string;\n /**\n * Link color\n */\n color?: LinkColor | `${LinkColor}`;\n /**\n * Click handler\n */\n onClick?: () => void;\n /**\n * Children content\n */\n children?: string;\n /**\n * Additional CSS classes\n */\n className?: string;\n} & Omit<\n HTMLAttributes<HTMLAnchorElement>,\n 'href' | 'onClick' | 'color' | 'children' | 'className'\n>;\n\n/**\n * Maps LinkColor to corresponding Tailwind text color classes\n */\nconst getColorClass = (color?: LinkColor | `${LinkColor}`): string => {\n if (!color) return '';\n\n const colorMap: Record<LinkColor, string> = {\n primary: 'text-primary',\n secondary: 'text-secondary',\n neutral: 'text-neutral',\n light: 'text-white',\n dark: 'text-neutral-800',\n text: 'text-text',\n 'text-inverse': 'text-text-opposite',\n error: 'text-error',\n success: 'text-success',\n custom: '',\n };\n\n return colorMap[color as LinkColor] || '';\n};\n\n/**\n * Breadcrumb variant styles using class-variance-authority\n */\nconst breadcrumbVariants = cva('flex flex-row flex-wrap items-center text-sm', {\n variants: {\n size: {\n small: 'gap-1 text-xs',\n medium: 'gap-2 text-sm',\n large: 'gap-3 text-base',\n },\n spacing: {\n compact: 'gap-1',\n normal: 'gap-2',\n loose: 'gap-4',\n },\n },\n defaultVariants: {\n size: 'medium',\n spacing: 'normal',\n },\n});\n\n/**\n * LinkLink sub-component for breadcrumb items that navigate to other pages\n */\nconst LinkLink: FC<LinkLinkProps> = ({\n href,\n lang,\n children,\n onClick,\n color,\n position,\n locale,\n className,\n ...props\n}) => {\n const content = getIntlayer('breadcrumb');\n const linkLabel = content.linkLabel;\n\n return (\n <>\n <Link\n href={href}\n locale={locale}\n color={color}\n onClick={onClick}\n itemProp=\"item\"\n isExternalLink={false}\n itemScope\n itemType=\"https://schema.org/WebPage\"\n {...props}\n label={`${linkLabel} ${children}`}\n itemID={href}\n size=\"sm\"\n >\n <span itemProp=\"name\">{children}</span>\n </Link>\n <meta itemProp=\"position\" content={position.toString()} />\n </>\n );\n};\n\n/**\n * Props for ButtonLink sub-component that renders breadcrumb items as interactive buttons\n */\ntype ButtonButtonProps = {\n /**\n * Text content for the breadcrumb button\n */\n children: string;\n /**\n * Position of the breadcrumb item in the list (1-based index)\n */\n position: number;\n} & Omit<ButtonProps, 'children' | 'label'>;\n\n/**\n * ButtonLink sub-component for breadcrumb items with click handlers\n */\nconst ButtonLink: FC<ButtonButtonProps> = ({\n children: text,\n onClick,\n color,\n position,\n className,\n ...props\n}) => {\n const { linkLabel } = useIntlayer('breadcrumb');\n\n return (\n <>\n <Button\n onClick={onClick}\n variant=\"link\"\n label={`${linkLabel} ${text}`}\n color={color}\n itemProp=\"item\"\n {...props}\n >\n <span itemProp=\"name\">{text}</span>\n </Button>\n <meta itemProp=\"position\" content={position.toString()} />\n </>\n );\n};\n\n/**\n * Props for Span sub-component that renders static breadcrumb text\n */\ntype SpanProps = {\n /**\n * Text content for the static breadcrumb item\n */\n children: string;\n /**\n * Position of the breadcrumb item in the list (1-based index)\n */\n position: number;\n} & HTMLAttributes<HTMLSpanElement>;\n\n/**\n * Span sub-component for static breadcrumb text items\n */\nconst Span: FC<SpanProps> = ({ children, position, className, ...props }) => (\n <span\n itemProp=\"item\"\n className={cn(\n 'inline-flex items-center',\n 'font-medium text-neutral-700',\n 'transition-colors duration-200',\n className\n )}\n >\n <span itemProp=\"name\" {...props}>\n {children}\n </span>\n <meta itemProp=\"position\" content={position.toString()} />\n </span>\n);\n\n/**\n * Detailed breadcrumb link configuration with optional href or onClick\n */\ntype DetailedBreadcrumbLink = {\n /**\n * URL to navigate to when the breadcrumb item is clicked\n */\n href?: string;\n /**\n * Text content to display for this breadcrumb item\n */\n text: string;\n /**\n * Custom click handler function for interactive breadcrumb items\n */\n onClick?: () => void;\n};\n\n/**\n * Union type representing different breadcrumb item configurations:\n * - string: Simple text breadcrumb item\n * - DetailedBreadcrumbLink: Object with href, text, and/or onClick properties\n */\nexport type BreadcrumbLink = string | DetailedBreadcrumbLink;\n\nexport type BreadcrumbProps = {\n /**\n * Array of breadcrumb items\n */\n links: BreadcrumbLink[];\n /**\n * Color scheme for breadcrumb links\n * @default \"text\"\n */\n color?: LinkColor | `${LinkColor}`;\n /**\n * Locale for internationalization\n */\n locale?: LocalesValues;\n /**\n * Element type for ARIA current attribute\n * @default 'page'\n */\n elementType?: 'page' | 'location';\n /**\n * Custom separator between breadcrumb items\n * @default ChevronRightIcon\n */\n separator?: ReactNode;\n /**\n * ARIA label for breadcrumb navigation\n * @default 'breadcrumb'\n */\n ariaLabel?: string;\n /**\n * Whether to include structured data markup\n * @default true\n */\n includeStructuredData?: boolean;\n /**\n * Maximum number of breadcrumb items to show before truncation\n */\n maxItems?: number;\n} & VariantProps<typeof breadcrumbVariants> &\n HTMLAttributes<HTMLOListElement>;\n\n/**\n * Breadcrumb component providing navigational context with accessibility features\n *\n * Features:\n * - Supports links, buttons, and static text elements\n * - Full keyboard navigation support\n * - ARIA attributes for screen readers\n * - Schema.org structured data for SEO\n * - Customizable separators and styling\n * - Internationalization support\n * - Responsive design variants\n *\n * @example\n * ```tsx\n * <Breadcrumb\n * links={[\n * 'Home',\n * { href: '/products', text: 'Products' },\n * { onClick: handleCategory, text: 'Electronics' },\n * 'Smartphones'\n * ]}\n * size=\"medium\"\n * ariaLabel=\"Product navigation\"\n * />\n * ```\n */\nexport const Breadcrumb: FC<BreadcrumbProps> = ({\n links,\n className,\n color = 'text',\n locale,\n elementType = 'page',\n separator = <ChevronRightIcon size={10} />,\n ariaLabel = 'breadcrumb',\n includeStructuredData = true,\n maxItems,\n size,\n spacing,\n ...props\n}) => {\n const displayLinks =\n maxItems && links.length > maxItems\n ? [...links.slice(0, 1), '...', ...links.slice(-(maxItems - 2))]\n : links;\n\n return (\n <nav aria-label={ariaLabel}>\n <ol\n className={cn(breadcrumbVariants({ size, spacing }), className)}\n {...(includeStructuredData && {\n itemScope: true,\n itemType: 'http://schema.org/BreadcrumbList',\n })}\n {...props}\n >\n {displayLinks.map((link, index) => {\n const isLastLink = index === displayLinks.length - 1;\n const isLink =\n typeof link === 'object' && typeof link.href === 'string';\n const isButton =\n typeof link === 'object' && typeof link.onClick === 'function';\n const isActive = index === displayLinks.length - 1;\n const ariaCurrent = isActive ? elementType : undefined;\n const isTruncated = link === '...';\n\n const text = (link as DetailedBreadcrumbLink).text ?? link;\n\n const separatorColorClass = getColorClass(color);\n\n if (isTruncated) {\n return (\n <Fragment key={`truncated-${text}`}>\n <li className=\"flex items-center\" aria-hidden=\"true\">\n <span className=\"text-neutral-500\">…</span>\n </li>\n {!isLastLink && (\n <li aria-hidden=\"true\" className=\"flex items-center\">\n <span className={cn(separatorColorClass)}>{separator}</span>\n </li>\n )}\n </Fragment>\n );\n }\n\n let section = (\n <Span\n key={text}\n position={index + 1}\n aria-current={ariaCurrent}\n className={cn(\n 'transition-colors duration-200',\n isActive && 'text-neutral-900'\n )}\n >\n {text}\n </Span>\n );\n\n if (isLink) {\n section = (\n <LinkLink\n key={text}\n href={link.href!}\n color={color}\n position={index + 1}\n locale={locale}\n aria-current={ariaCurrent}\n className={cn(isActive && 'cursor-default text-neutral-900')}\n >\n {text}\n </LinkLink>\n );\n } else if (isButton) {\n section = (\n <ButtonLink\n key={text}\n onClick={link.onClick!}\n color={color}\n position={index + 1}\n aria-current={ariaCurrent}\n className={cn(isActive && 'cursor-default text-neutral-900')}\n >\n {text}\n </ButtonLink>\n );\n }\n\n const listElement = (\n <li\n {...(includeStructuredData && {\n itemProp: 'itemListElement',\n itemScope: true,\n itemType: 'https://schema.org/ListItem',\n })}\n key={text}\n className=\"flex items-center\"\n >\n {section}\n </li>\n );\n\n if (isLastLink) {\n return listElement;\n }\n\n return (\n <Fragment key={text}>\n {listElement}\n <li aria-hidden=\"true\" className=\"flex items-center\">\n <span className={cn(separatorColorClass)}>{separator}</span>\n </li>\n </Fragment>\n );\n })}\n </ol>\n </nav>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAoDA,MAAM,iBAAiB,UAA+C;CACpE,IAAI,CAAC,OAAO,OAAO;CAenB,OAAO;EAZL,SAAS;EACT,WAAW;EACX,SAAS;EACT,O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,gBAAc;KACd,WAAW,GACT,kCACA,YAAY,kBACd;eAEC;IACG,GATC,IASD;IAGR,IAAI,QACF,UACE,oBAAC,UAAD;KAEE,MAAM,KAAK;KACJ;KACP,UAAU,QAAQ;KACV;KACR,gBAAc;KACd,WAAW,GAAG,YAAY,iCAAiC;eAE1D;IACO,GATH,IASG;SAEP,IAAI,UACT,UACE,oBAAC,YAAD;KAEE,SAAS,KAAK;KACP;KACP,UAAU,QAAQ;KAClB,gBAAc;KACd,WAAW,GAAG,YAAY,iCAAiC;eAE1D;IACS,GARL,IAQK;IAIhB,MAAM,cACJ,8BAAC,MAAD;KACE,GAAK,yBAAyB;MAC5B,UAAU;MACV,WAAW;MACX,UAAU;KACZ;KACA,KAAK;KACL,WAAU;IAGR,GADD,OACC;IAGN,IAAI,YACF,OAAO;IAGT,OACE,qBAAC,UAAD,aACG,aACD,oBAAC,MAAD;KAAI,eAAY;KAAO,WAAU;eAC/B,oBAAC,QAAD;MAAM,WAAW,GAAG,mBAAmB;gBAAI;KAAgB;IACzD,EACI,KALK,IAKL;GAEd,CAAC;EACC;CACD;AAET"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { cn } from "../../utils/cn.mjs";
|
|
4
|
-
import { Container } from "../Container/index.mjs";
|
|
5
4
|
import { Button } from "../Button/Button.mjs";
|
|
5
|
+
import { Container } from "../Container/index.mjs";
|
|
6
6
|
import { ClickOutsideDiv } from "../ClickOutsideDiv/index.mjs";
|
|
7
7
|
import { DropDown } from "../DropDown/index.mjs";
|
|
8
8
|
import { Input, inputVariants } from "../Input/Input.mjs";
|