@intlayer/design-system 8.2.3 → 8.3.0-canary.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.
Files changed (209) hide show
  1. package/dist/esm/components/Accordion/Accordion.mjs +1 -1
  2. package/dist/esm/components/Avatar/index.mjs +1 -1
  3. package/dist/esm/components/Breadcrumb/index.mjs +1 -1
  4. package/dist/esm/components/Breadcrumb/index.mjs.map +1 -1
  5. package/dist/esm/components/Browser/Browser.mjs +1 -1
  6. package/dist/esm/components/Carousel/index.mjs +4 -4
  7. package/dist/esm/components/CollapsibleTable/CollapsibleTable.mjs +1 -1
  8. package/dist/esm/components/ContentEditor/ContentEditor.mjs +1 -1
  9. package/dist/esm/components/ContentEditor/ContentEditorInput.mjs +1 -1
  10. package/dist/esm/components/ContentEditor/ContentEditorTextArea.mjs +1 -1
  11. package/dist/esm/components/CopyButton/index.mjs +1 -1
  12. package/dist/esm/components/CopyToClipboard/index.mjs +1 -1
  13. package/dist/esm/components/DictionaryEditor/DictionaryEditor.mjs.map +1 -1
  14. package/dist/esm/components/DictionaryEditor/NodeWrapper/ArrayWrapper.mjs +1 -1
  15. package/dist/esm/components/DictionaryEditor/NodeWrapper/ArrayWrapper.mjs.map +1 -1
  16. package/dist/esm/components/DictionaryEditor/NodeWrapper/ConditionWrapper.mjs +1 -1
  17. package/dist/esm/components/DictionaryEditor/NodeWrapper/ConditionWrapper.mjs.map +1 -1
  18. package/dist/esm/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.mjs +1 -1
  19. package/dist/esm/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.mjs.map +1 -1
  20. package/dist/esm/components/DictionaryEditor/NodeWrapper/FileWrapper.mjs +1 -1
  21. package/dist/esm/components/DictionaryEditor/NodeWrapper/FileWrapper.mjs.map +1 -1
  22. package/dist/esm/components/DictionaryEditor/NodeWrapper/HtmlWrapper.mjs +1 -1
  23. package/dist/esm/components/DictionaryEditor/NodeWrapper/HtmlWrapper.mjs.map +1 -1
  24. package/dist/esm/components/DictionaryEditor/NodeWrapper/InsertionWrapper.mjs +1 -1
  25. package/dist/esm/components/DictionaryEditor/NodeWrapper/InsertionWrapper.mjs.map +1 -1
  26. package/dist/esm/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.mjs +1 -1
  27. package/dist/esm/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.mjs.map +1 -1
  28. package/dist/esm/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.mjs +1 -1
  29. package/dist/esm/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.mjs.map +1 -1
  30. package/dist/esm/components/DictionaryEditor/NodeWrapper/TranslationWrapper.mjs +1 -1
  31. package/dist/esm/components/DictionaryEditor/NodeWrapper/TranslationWrapper.mjs.map +1 -1
  32. package/dist/esm/components/DictionaryEditor/NodeWrapper/index.mjs +1 -1
  33. package/dist/esm/components/DictionaryEditor/NodeWrapper/index.mjs.map +1 -1
  34. package/dist/esm/components/DictionaryFieldEditor/ContentEditor.mjs.map +1 -1
  35. package/dist/esm/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs +1 -1
  36. package/dist/esm/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs.map +1 -1
  37. package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +1 -1
  38. package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map +1 -1
  39. package/dist/esm/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +1 -1
  40. package/dist/esm/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
  41. package/dist/esm/components/DictionaryFieldEditor/JSONEditor.mjs.map +1 -1
  42. package/dist/esm/components/DictionaryFieldEditor/KeyPathBreadcrumb.mjs.map +1 -1
  43. package/dist/esm/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +1 -1
  44. package/dist/esm/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs.map +1 -1
  45. package/dist/esm/components/DictionaryFieldEditor/NodeTypeSelector.mjs +1 -1
  46. package/dist/esm/components/DictionaryFieldEditor/NodeTypeSelector.mjs.map +1 -1
  47. package/dist/esm/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +1 -1
  48. package/dist/esm/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
  49. package/dist/esm/components/DictionaryFieldEditor/StructureEditor.mjs.map +1 -1
  50. package/dist/esm/components/DictionaryFieldEditor/StructureView/StructureView.mjs +1 -1
  51. package/dist/esm/components/DictionaryFieldEditor/StructureView/StructureView.mjs.map +1 -1
  52. package/dist/esm/components/DictionaryFieldEditor/getIsEditableSection.mjs +1 -1
  53. package/dist/esm/components/DictionaryFieldEditor/getIsEditableSection.mjs.map +1 -1
  54. package/dist/esm/components/EditableField/EditableFieldLayout.mjs +1 -1
  55. package/dist/esm/components/ExpandCollapse/ExpandCollapse.mjs +1 -1
  56. package/dist/esm/components/ExpandCollapse/ExpandCollapse.mjs.map +1 -1
  57. package/dist/esm/components/Flags/Flag.mjs +1 -1
  58. package/dist/esm/components/Flags/Flag.mjs.map +1 -1
  59. package/dist/esm/components/HTMLRender/HTMLRender.mjs.map +1 -1
  60. package/dist/esm/components/HideShow/index.mjs +1 -1
  61. package/dist/esm/components/IDE/CodeBlockClient.mjs.map +1 -1
  62. package/dist/esm/components/IDE/CodeBlockShiki.mjs +1 -1
  63. package/dist/esm/components/IDE/CodeBlockShiki.mjs.map +1 -1
  64. package/dist/esm/components/IDE/FileTree.mjs +1 -1
  65. package/dist/esm/components/Input/Input.mjs +1 -1
  66. package/dist/esm/components/Input/Input.mjs.map +1 -1
  67. package/dist/esm/components/Input/InputPassword.mjs +1 -1
  68. package/dist/esm/components/Input/OTPInput.mjs +2 -2
  69. package/dist/esm/components/Label/index.mjs +1 -1
  70. package/dist/esm/components/Label/index.mjs.map +1 -1
  71. package/dist/esm/components/LanguageBackground/index.mjs +1 -1
  72. package/dist/esm/components/LanguageBackground/index.mjs.map +1 -1
  73. package/dist/esm/components/Link/Link.mjs +1 -1
  74. package/dist/esm/components/Link/Link.mjs.map +1 -1
  75. package/dist/esm/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs +1 -1
  76. package/dist/esm/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs.map +1 -1
  77. package/dist/esm/components/LocaleSwitcherDropDown/LocaleSwitcher.mjs +1 -1
  78. package/dist/esm/components/LocaleSwitcherDropDown/LocaleSwitcher.mjs.map +1 -1
  79. package/dist/esm/components/MarkDownRender/MarkDownRender.mjs +1 -1
  80. package/dist/esm/components/MarkDownRender/MarkDownRender.mjs.map +1 -1
  81. package/dist/esm/components/MarkDownRender/index.mjs +1 -1
  82. package/dist/esm/components/MaxHeightSmoother/index.mjs +1 -1
  83. package/dist/esm/components/MaxHeightSmoother/index.mjs.map +1 -1
  84. package/dist/esm/components/Modal/Modal.mjs +1 -1
  85. package/dist/esm/components/Pagination/Pagination.mjs +1 -1
  86. package/dist/esm/components/RightDrawer/RightDrawer.mjs +1 -1
  87. package/dist/esm/components/Select/Multiselect.mjs +1 -1
  88. package/dist/esm/components/Select/Select.mjs +1 -1
  89. package/dist/esm/components/Select/Select.mjs.map +1 -1
  90. package/dist/esm/components/Table/Table.mjs +1 -1
  91. package/dist/esm/components/ThemeSwitcherDropDown/DesktopThemeSwitcher.mjs +1 -1
  92. package/dist/esm/components/ThemeSwitcherDropDown/MobileThemeSwitcher.mjs +1 -1
  93. package/dist/esm/components/Toaster/Toast.mjs +1 -1
  94. package/dist/esm/components/index.mjs +1 -1
  95. package/dist/esm/hooks/index.mjs +1 -1
  96. package/dist/esm/hooks/reactQuery.mjs +1 -1
  97. package/dist/esm/hooks/reactQuery.mjs.map +1 -1
  98. package/dist/esm/hooks/useAuth/useAuth.mjs.map +1 -1
  99. package/dist/esm/hooks/useAuth/useOAuth2.mjs +1 -1
  100. package/dist/esm/hooks/useAuth/useOAuth2.mjs.map +1 -1
  101. package/dist/esm/hooks/useAuth/useSession.mjs +1 -1
  102. package/dist/esm/hooks/useAuth/useSession.mjs.map +1 -1
  103. package/dist/esm/hooks/useIntlayerAPI.mjs.map +1 -1
  104. package/dist/esm/libs/auth.mjs +1 -1
  105. package/dist/esm/libs/auth.mjs.map +1 -1
  106. package/dist/esm/providers/ReactQueryProvider.mjs +1 -1
  107. package/dist/types/components/Badge/index.d.ts +1 -1
  108. package/dist/types/components/Breadcrumb/breadcrumb.content.d.ts +3 -3
  109. package/dist/types/components/Breadcrumb/index.d.ts +1 -1
  110. package/dist/types/components/Browser/Browser.content.d.ts +17 -17
  111. package/dist/types/components/Button/Button.d.ts +3 -3
  112. package/dist/types/components/Carousel/index.content.d.ts +7 -7
  113. package/dist/types/components/CollapsibleTable/CollapsibleTable.d.ts +2 -2
  114. package/dist/types/components/Command/index.d.ts +1 -1
  115. package/dist/types/components/Container/index.d.ts +5 -5
  116. package/dist/types/components/CopyButton/CopyButton.content.d.ts +3 -3
  117. package/dist/types/components/DictionaryEditor/DictionaryEditor.d.ts +2 -1
  118. package/dist/types/components/DictionaryEditor/DictionaryEditor.d.ts.map +1 -1
  119. package/dist/types/components/DictionaryEditor/NodeWrapper/ArrayWrapper.d.ts +1 -1
  120. package/dist/types/components/DictionaryEditor/NodeWrapper/ArrayWrapper.d.ts.map +1 -1
  121. package/dist/types/components/DictionaryEditor/NodeWrapper/ConditionWrapper.d.ts +1 -1
  122. package/dist/types/components/DictionaryEditor/NodeWrapper/ConditionWrapper.d.ts.map +1 -1
  123. package/dist/types/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.d.ts +1 -1
  124. package/dist/types/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.d.ts.map +1 -1
  125. package/dist/types/components/DictionaryEditor/NodeWrapper/FileWrapper.d.ts.map +1 -1
  126. package/dist/types/components/DictionaryEditor/NodeWrapper/HtmlWrapper.d.ts +1 -1
  127. package/dist/types/components/DictionaryEditor/NodeWrapper/HtmlWrapper.d.ts.map +1 -1
  128. package/dist/types/components/DictionaryEditor/NodeWrapper/InsertionWrapper.d.ts +1 -1
  129. package/dist/types/components/DictionaryEditor/NodeWrapper/InsertionWrapper.d.ts.map +1 -1
  130. package/dist/types/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.d.ts +1 -1
  131. package/dist/types/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.d.ts.map +1 -1
  132. package/dist/types/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.d.ts +1 -1
  133. package/dist/types/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.d.ts.map +1 -1
  134. package/dist/types/components/DictionaryEditor/NodeWrapper/TranslationWrapper.d.ts +1 -1
  135. package/dist/types/components/DictionaryEditor/NodeWrapper/TranslationWrapper.d.ts.map +1 -1
  136. package/dist/types/components/DictionaryEditor/NodeWrapper/index.d.ts +3 -1
  137. package/dist/types/components/DictionaryEditor/NodeWrapper/index.d.ts.map +1 -1
  138. package/dist/types/components/DictionaryFieldEditor/ContentEditor.d.ts +1 -1
  139. package/dist/types/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts +2 -1
  140. package/dist/types/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts.map +1 -1
  141. package/dist/types/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryCreationForm.content.d.ts +25 -25
  142. package/dist/types/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.content.d.ts +9 -9
  143. package/dist/types/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.d.ts +1 -1
  144. package/dist/types/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.d.ts +55 -55
  145. package/dist/types/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.content.d.ts +33 -33
  146. package/dist/types/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts +1 -1
  147. package/dist/types/components/DictionaryFieldEditor/JSONEditor.d.ts +1 -1
  148. package/dist/types/components/DictionaryFieldEditor/KeyPathBreadcrumb.d.ts +2 -1
  149. package/dist/types/components/DictionaryFieldEditor/KeyPathBreadcrumb.d.ts.map +1 -1
  150. package/dist/types/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.d.ts +4 -4
  151. package/dist/types/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.d.ts.map +1 -1
  152. package/dist/types/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.d.ts +25 -25
  153. package/dist/types/components/DictionaryFieldEditor/NodeTypeSelector.d.ts +2 -1
  154. package/dist/types/components/DictionaryFieldEditor/NodeTypeSelector.d.ts.map +1 -1
  155. package/dist/types/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts +1 -1
  156. package/dist/types/components/DictionaryFieldEditor/SaveForm/saveForm.content.d.ts +33 -33
  157. package/dist/types/components/DictionaryFieldEditor/StructureEditor.d.ts +1 -1
  158. package/dist/types/components/DictionaryFieldEditor/StructureView/StructureView.d.ts +2 -1
  159. package/dist/types/components/DictionaryFieldEditor/StructureView/StructureView.d.ts.map +1 -1
  160. package/dist/types/components/DictionaryFieldEditor/StructureView/structureView.content.d.ts +9 -9
  161. package/dist/types/components/DictionaryFieldEditor/VersionSwitcherDropDown/versionSwitcherDropDown.content.d.ts +7 -7
  162. package/dist/types/components/DictionaryFieldEditor/dictionaryFieldEditor.content.d.ts +5 -5
  163. package/dist/types/components/DictionaryFieldEditor/getIsEditableSection.d.ts +1 -1
  164. package/dist/types/components/DictionaryFieldEditor/getIsEditableSection.d.ts.map +1 -1
  165. package/dist/types/components/DictionaryFieldEditor/nodeTypeSelector.content.d.ts +31 -31
  166. package/dist/types/components/ExpandCollapse/expandCollapse.content.d.ts +3 -3
  167. package/dist/types/components/Flags/Flag.d.ts +1 -1
  168. package/dist/types/components/Flags/Flag.d.ts.map +1 -1
  169. package/dist/types/components/HTMLRender/HTMLRender.d.ts +1 -1
  170. package/dist/types/components/IDE/CodeBlockClient.d.ts +2 -2
  171. package/dist/types/components/IDE/CodeBlockClient.d.ts.map +1 -1
  172. package/dist/types/components/IDE/CodeBlockShiki.d.ts.map +1 -1
  173. package/dist/types/components/IDE/code.content.d.ts +5 -5
  174. package/dist/types/components/IDE/copyCode.content.d.ts +5 -5
  175. package/dist/types/components/IDE/index.d.ts +2 -2
  176. package/dist/types/components/IDE/selectors.content.d.ts +13 -13
  177. package/dist/types/components/Input/Checkbox.d.ts +1 -1
  178. package/dist/types/components/LanguageBackground/index.d.ts.map +1 -1
  179. package/dist/types/components/Link/Link.d.ts +4 -4
  180. package/dist/types/components/Loader/index.content.d.ts +3 -3
  181. package/dist/types/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.d.ts.map +1 -1
  182. package/dist/types/components/LocaleSwitcherContentDropDown/localeSwitcher.content.d.ts +17 -17
  183. package/dist/types/components/LocaleSwitcherDropDown/LocaleSwitcher.d.ts +1 -1
  184. package/dist/types/components/LocaleSwitcherDropDown/LocaleSwitcher.d.ts.map +1 -1
  185. package/dist/types/components/LocaleSwitcherDropDown/localeSwitcher.content.d.ts +13 -13
  186. package/dist/types/components/MarkDownRender/MarkDownRender.d.ts +143 -15
  187. package/dist/types/components/MarkDownRender/MarkDownRender.d.ts.map +1 -1
  188. package/dist/types/components/MarkDownRender/index.d.ts +2 -2
  189. package/dist/types/components/Pagination/Pagination.d.ts +2 -2
  190. package/dist/types/components/Pagination/pagination.content.d.ts +11 -11
  191. package/dist/types/components/RightDrawer/rightDrawer.content.d.ts +5 -5
  192. package/dist/types/components/Select/Select.d.ts.map +1 -1
  193. package/dist/types/components/SwitchSelector/index.d.ts +1 -1
  194. package/dist/types/components/Tab/Tab.d.ts +2 -2
  195. package/dist/types/components/TabSelector/TabSelector.d.ts +1 -1
  196. package/dist/types/components/Table/table.content.d.ts +3 -3
  197. package/dist/types/components/Tag/index.d.ts +2 -2
  198. package/dist/types/components/Terminal/terminal.content.d.ts +5 -5
  199. package/dist/types/components/index.d.ts +3 -3
  200. package/dist/types/hooks/index.d.ts +3 -3
  201. package/dist/types/hooks/reactQuery.d.ts +11 -3
  202. package/dist/types/hooks/reactQuery.d.ts.map +1 -1
  203. package/dist/types/hooks/useAuth/useAuth.d.ts +1 -1
  204. package/dist/types/hooks/useAuth/useOAuth2.d.ts +1 -1
  205. package/dist/types/hooks/useAuth/useSession.d.ts +1 -1
  206. package/dist/types/hooks/useIntlayerAPI.d.ts +2 -2
  207. package/dist/types/hooks/useIntlayerAPI.d.ts.map +1 -1
  208. package/dist/types/libs/auth.d.ts +1 -1
  209. package/package.json +31 -29
@@ -1,2 +1,2 @@
1
- "use client";import{CodeDefault as e}from"./CodeBlockClient.mjs";import{useEffect as t,useState as n}from"react";import{jsx as r}from"react/jsx-runtime";const i=new Map,a=new Map,o=async e=>{if(i.has(e))return i.get(e);let t;switch(e){case`typescript`:case`ts`:t=await import(`shiki/langs/typescript.mjs`);break;case`javascript`:case`js`:t=await import(`shiki/langs/javascript.mjs`);break;case`bash`:case`sh`:case`shell`:t=await import(`shiki/langs/bash.mjs`);break;case`json`:t=await import(`shiki/langs/json.mjs`);break;case`tsx`:t=await import(`shiki/langs/tsx.mjs`);break;case`vue`:t=await import(`shiki/langs/vue.mjs`);break;case`html`:t=await import(`shiki/langs/html.mjs`);break;default:t=await import(`shiki/langs/typescript.mjs`);break}let n=t.default;return i.set(e,n),n},s=async e=>{if(a.has(e))return a.get(e);let t;switch(e){case`github-dark`:t=await import(`shiki/themes/github-dark.mjs`);break;default:t=await import(`shiki/themes/github-light.mjs`);break}let n=t.default;return a.set(e,n),n};let c=null;const l=async()=>(c||=import(`shiki/bundle/web`).then(({createHighlighter:e})=>e({langs:[],themes:[]})),c),u=async(e,t,n)=>{let r=n?`github-dark`:`github-light`,[i,a,c]=await Promise.all([l(),o(t),s(r)]);return i.getLoadedLanguages().includes(t)||await i.loadLanguage(a),i.getLoadedThemes().includes(r)||await i.loadTheme(c),i.codeToHtml(e,{lang:t,theme:r})},d=({children:i,lang:a,isDarkMode:o})=>{let[s,c]=n(null);return t(()=>{let e=!1;return u(i,a,o).then(t=>{e||c(t)}).catch(t=>{console.error(`Failed to highlight code:`,t),!e&&s===null&&c(``)}),()=>{e=!0}},[i,a,o]),r(`div`,{className:`min-w-0 max-w-full overflow-auto bg-transparent [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden [&_pre::-webkit-scrollbar]:hidden [&_pre]:[-ms-overflow-style:none] [&_pre]:[scrollbar-width:none]`,children:s?r(`div`,{dangerouslySetInnerHTML:{__html:s}}):r(e,{children:i})})};export{d as CodeBlockShiki};
1
+ "use client";import{CodeDefault as e}from"./CodeBlockClient.mjs";import{useEffect as t,useState as n}from"react";import{jsx as r}from"react/jsx-runtime";const i=new Map,a=new Map,o=async e=>{if(i.has(e))return i.get(e);let t;switch(e){case`typescript`:case`ts`:t=await import(`shiki/langs/typescript.mjs`);break;case`javascript`:case`js`:t=await import(`shiki/langs/javascript.mjs`);break;case`bash`:case`sh`:case`shell`:t=await import(`shiki/langs/bash.mjs`);break;case`json`:t=await import(`shiki/langs/json.mjs`);break;case`tsx`:t=await import(`shiki/langs/tsx.mjs`);break;case`vue`:t=await import(`shiki/langs/vue.mjs`);break;case`html`:t=await import(`shiki/langs/html.mjs`);break;case`xml`:t=await import(`shiki/langs/xml.mjs`);break;case`yaml`:t=await import(`shiki/langs/yaml.mjs`);break;default:t=await import(`shiki/langs/typescript.mjs`);break}let n=t.default;return i.set(e,n),n},s=async e=>{if(a.has(e))return a.get(e);let t;switch(e){case`github-dark`:t=await import(`shiki/themes/github-dark.mjs`);break;default:t=await import(`shiki/themes/github-light.mjs`);break}let n=t.default;return a.set(e,n),n};let c=null;const l=async()=>(c||=import(`shiki/bundle/web`).then(({createHighlighter:e})=>e({langs:[],themes:[]})),c),u=async(e,t,n)=>{let r=n?`github-dark`:`github-light`,[i,a,c]=await Promise.all([l(),o(t),s(r)]);return i.getLoadedLanguages().includes(t)||await i.loadLanguage(a),i.getLoadedThemes().includes(r)||await i.loadTheme(c),i.codeToHtml(e,{lang:t,theme:r})},d=({children:i,lang:a,isDarkMode:o})=>{let[s,c]=n(null);return t(()=>{let e=!1;return u(i,a,o).then(t=>{e||c(t)}).catch(t=>{console.error(`Failed to highlight code:`,t),!e&&s===null&&c(``)}),()=>{e=!0}},[i,a,o]),r(`div`,{className:`min-w-0 max-w-full overflow-auto bg-transparent [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden [&_pre::-webkit-scrollbar]:hidden [&_pre]:[-ms-overflow-style:none] [&_pre]:[scrollbar-width:none]`,children:s?r(`div`,{dangerouslySetInnerHTML:{__html:s}}):r(e,{children:i})})};export{d as CodeBlockShiki};
2
2
  //# sourceMappingURL=CodeBlockShiki.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"CodeBlockShiki.mjs","names":[],"sources":["../../../../src/components/IDE/CodeBlockShiki.tsx"],"sourcesContent":["'use client';\n\nimport { type FC, useEffect, useState } from 'react';\nimport type {\n BundledLanguage,\n BundledTheme,\n HighlighterGeneric,\n} from 'shiki/bundle/web';\nimport { CodeDefault } from './CodeBlockClient';\n\n// Map of loaded modules to avoid re-importing\nconst languageCache = new Map<BundledLanguage, any>();\nconst themeCache = new Map<BundledTheme, any>();\n\n// Lazy load language modules\nconst loadLanguage = async (lang: BundledLanguage): Promise<any> => {\n if (languageCache.has(lang)) return languageCache.get(lang);\n\n let languageModule: any;\n switch (lang) {\n case 'typescript':\n case 'ts':\n languageModule = await import('shiki/langs/typescript.mjs');\n break;\n case 'javascript':\n case 'js':\n languageModule = await import('shiki/langs/javascript.mjs');\n break;\n case 'bash':\n case 'sh':\n case 'shell':\n languageModule = await import('shiki/langs/bash.mjs');\n break;\n case 'json':\n languageModule = await import('shiki/langs/json.mjs');\n break;\n case 'tsx':\n languageModule = await import('shiki/langs/tsx.mjs');\n break;\n case 'vue':\n languageModule = await import('shiki/langs/vue.mjs');\n break;\n case 'html':\n languageModule = await import('shiki/langs/html.mjs');\n break;\n default:\n languageModule = await import('shiki/langs/typescript.mjs');\n break;\n }\n\n const language = languageModule.default;\n languageCache.set(lang, language);\n return language;\n};\n\n// Lazy load theme modules\nconst loadTheme = async (themeName: BundledTheme): Promise<any> => {\n if (themeCache.has(themeName)) return themeCache.get(themeName);\n\n let themeModule: any;\n switch (themeName) {\n case 'github-dark':\n themeModule = await import('shiki/themes/github-dark.mjs');\n break;\n case 'github-light':\n default:\n themeModule = await import('shiki/themes/github-light.mjs');\n break;\n }\n\n const theme = themeModule.default;\n themeCache.set(themeName, theme);\n return theme;\n};\n\n// Singleton Highlighter Instance\nlet highlighterPromise: Promise<HighlighterGeneric<any, any>> | null = null;\n\nconst getHighlighterInstance = async () => {\n if (!highlighterPromise) {\n highlighterPromise = import('shiki/bundle/web').then(\n ({ createHighlighter }) =>\n createHighlighter({\n langs: [],\n themes: [],\n })\n );\n }\n return highlighterPromise;\n};\n\n// Create a promise for highlighting\nconst highlightCode = async (\n code: string,\n lang: BundledLanguage,\n isDarkMode?: boolean\n): Promise<string> => {\n const themeName: BundledTheme = isDarkMode ? 'github-dark' : 'github-light';\n\n // Load highlighter, language, and theme in parallel\n const [highlighter, languageModule, themeModule] = await Promise.all([\n getHighlighterInstance(),\n loadLanguage(lang),\n loadTheme(themeName),\n ]);\n\n // Load into the singleton instance if not already loaded\n if (!highlighter.getLoadedLanguages().includes(lang)) {\n await highlighter.loadLanguage(languageModule);\n }\n if (!highlighter.getLoadedThemes().includes(themeName)) {\n await highlighter.loadTheme(themeModule);\n }\n\n return highlighter.codeToHtml(code, {\n lang,\n theme: themeName,\n });\n};\n\nexport type CodeBlockShikiProps = {\n children: string;\n lang: BundledLanguage;\n isDarkMode?: boolean;\n};\n\nexport const CodeBlockShiki: FC<CodeBlockShikiProps> = ({\n children,\n lang,\n isDarkMode,\n}) => {\n const [html, setHtml] = useState<string | null>(null);\n\n useEffect(() => {\n let isCancelled = false;\n\n highlightCode(children, lang, isDarkMode)\n .then((result) => {\n if (!isCancelled) setHtml(result);\n })\n .catch((error) => {\n console.error('Failed to highlight code:', error);\n if (!isCancelled && html === null) setHtml('');\n });\n\n return () => {\n isCancelled = true;\n };\n }, [children, lang, isDarkMode]);\n\n return (\n <div className=\"min-w-0 max-w-full overflow-auto bg-transparent [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden [&_pre::-webkit-scrollbar]:hidden [&_pre]:[-ms-overflow-style:none] [&_pre]:[scrollbar-width:none]\">\n {html ? (\n // biome-ignore lint/security/noDangerouslySetInnerHtml: Shiki generates safe HTML for code highlighting\n <div dangerouslySetInnerHTML={{ __html: html }} />\n ) : (\n <CodeDefault>{children}</CodeDefault>\n )}\n </div>\n );\n};\n"],"mappings":"yJAWA,MAAM,EAAgB,IAAI,IACpB,EAAa,IAAI,IAGjB,EAAe,KAAO,IAAwC,CAClE,GAAI,EAAc,IAAI,EAAK,CAAE,OAAO,EAAc,IAAI,EAAK,CAE3D,IAAI,EACJ,OAAQ,EAAR,CACE,IAAK,aACL,IAAK,KACH,EAAiB,MAAM,OAAO,8BAC9B,MACF,IAAK,aACL,IAAK,KACH,EAAiB,MAAM,OAAO,8BAC9B,MACF,IAAK,OACL,IAAK,KACL,IAAK,QACH,EAAiB,MAAM,OAAO,wBAC9B,MACF,IAAK,OACH,EAAiB,MAAM,OAAO,wBAC9B,MACF,IAAK,MACH,EAAiB,MAAM,OAAO,uBAC9B,MACF,IAAK,MACH,EAAiB,MAAM,OAAO,uBAC9B,MACF,IAAK,OACH,EAAiB,MAAM,OAAO,wBAC9B,MACF,QACE,EAAiB,MAAM,OAAO,8BAC9B,MAGJ,IAAM,EAAW,EAAe,QAEhC,OADA,EAAc,IAAI,EAAM,EAAS,CAC1B,GAIH,EAAY,KAAO,IAA0C,CACjE,GAAI,EAAW,IAAI,EAAU,CAAE,OAAO,EAAW,IAAI,EAAU,CAE/D,IAAI,EACJ,OAAQ,EAAR,CACE,IAAK,cACH,EAAc,MAAM,OAAO,gCAC3B,MAEF,QACE,EAAc,MAAM,OAAO,iCAC3B,MAGJ,IAAM,EAAQ,EAAY,QAE1B,OADA,EAAW,IAAI,EAAW,EAAM,CACzB,GAIT,IAAI,EAAmE,KAEvE,MAAM,EAAyB,UAC7B,AACE,IAAqB,OAAO,oBAAoB,MAC7C,CAAE,uBACD,EAAkB,CAChB,MAAO,EAAE,CACT,OAAQ,EAAE,CACX,CAAC,CACL,CAEI,GAIH,EAAgB,MACpB,EACA,EACA,IACoB,CACpB,IAAM,EAA0B,EAAa,cAAgB,eAGvD,CAAC,EAAa,EAAgB,GAAe,MAAM,QAAQ,IAAI,CACnE,GAAwB,CACxB,EAAa,EAAK,CAClB,EAAU,EAAU,CACrB,CAAC,CAUF,OAPK,EAAY,oBAAoB,CAAC,SAAS,EAAK,EAClD,MAAM,EAAY,aAAa,EAAe,CAE3C,EAAY,iBAAiB,CAAC,SAAS,EAAU,EACpD,MAAM,EAAY,UAAU,EAAY,CAGnC,EAAY,WAAW,EAAM,CAClC,OACA,MAAO,EACR,CAAC,EASS,GAA2C,CACtD,WACA,OACA,gBACI,CACJ,GAAM,CAAC,EAAM,GAAW,EAAwB,KAAK,CAmBrD,OAjBA,MAAgB,CACd,IAAI,EAAc,GAWlB,OATA,EAAc,EAAU,EAAM,EAAW,CACtC,KAAM,GAAW,CACX,GAAa,EAAQ,EAAO,EACjC,CACD,MAAO,GAAU,CAChB,QAAQ,MAAM,4BAA6B,EAAM,CAC7C,CAAC,GAAe,IAAS,MAAM,EAAQ,GAAG,EAC9C,KAES,CACX,EAAc,KAEf,CAAC,EAAU,EAAM,EAAW,CAAC,CAG9B,EAAC,MAAD,CAAK,UAAU,6OACZ,EAEC,EAAC,MAAD,CAAK,wBAAyB,CAAE,OAAQ,EAAM,CAAI,CAAA,CAElD,EAAC,EAAD,CAAc,WAAuB,CAAA,CAEnC,CAAA"}
1
+ {"version":3,"file":"CodeBlockShiki.mjs","names":[],"sources":["../../../../src/components/IDE/CodeBlockShiki.tsx"],"sourcesContent":["'use client';\n\nimport { type FC, useEffect, useState } from 'react';\nimport type {\n BundledLanguage,\n BundledTheme,\n HighlighterGeneric,\n} from 'shiki/bundle/web';\nimport { CodeDefault } from './CodeBlockClient';\n\n// Map of loaded modules to avoid re-importing\nconst languageCache = new Map<BundledLanguage, any>();\nconst themeCache = new Map<BundledTheme, any>();\n\n// Lazy load language modules\nconst loadLanguage = async (lang: BundledLanguage): Promise<any> => {\n if (languageCache.has(lang)) return languageCache.get(lang);\n\n let languageModule: any;\n switch (lang) {\n case 'typescript':\n case 'ts':\n languageModule = await import('shiki/langs/typescript.mjs');\n break;\n case 'javascript':\n case 'js':\n languageModule = await import('shiki/langs/javascript.mjs');\n break;\n case 'bash':\n case 'sh':\n case 'shell':\n languageModule = await import('shiki/langs/bash.mjs');\n break;\n case 'json':\n languageModule = await import('shiki/langs/json.mjs');\n break;\n case 'tsx':\n languageModule = await import('shiki/langs/tsx.mjs');\n break;\n case 'vue':\n languageModule = await import('shiki/langs/vue.mjs');\n break;\n case 'html':\n languageModule = await import('shiki/langs/html.mjs');\n break;\n case 'xml':\n languageModule = await import('shiki/langs/xml.mjs');\n break;\n case 'yaml':\n languageModule = await import('shiki/langs/yaml.mjs');\n break;\n default:\n languageModule = await import('shiki/langs/typescript.mjs');\n break;\n }\n\n const language = languageModule.default;\n languageCache.set(lang, language);\n return language;\n};\n\n// Lazy load theme modules\nconst loadTheme = async (themeName: BundledTheme): Promise<any> => {\n if (themeCache.has(themeName)) return themeCache.get(themeName);\n\n let themeModule: any;\n switch (themeName) {\n case 'github-dark':\n themeModule = await import('shiki/themes/github-dark.mjs');\n break;\n case 'github-light':\n default:\n themeModule = await import('shiki/themes/github-light.mjs');\n break;\n }\n\n const theme = themeModule.default;\n themeCache.set(themeName, theme);\n return theme;\n};\n\n// Singleton Highlighter Instance\nlet highlighterPromise: Promise<HighlighterGeneric<any, any>> | null = null;\n\nconst getHighlighterInstance = async () => {\n if (!highlighterPromise) {\n highlighterPromise = import('shiki/bundle/web').then(\n ({ createHighlighter }) =>\n createHighlighter({\n langs: [],\n themes: [],\n })\n );\n }\n return highlighterPromise;\n};\n\n// Create a promise for highlighting\nconst highlightCode = async (\n code: string,\n lang: BundledLanguage,\n isDarkMode?: boolean\n): Promise<string> => {\n const themeName: BundledTheme = isDarkMode ? 'github-dark' : 'github-light';\n\n // Load highlighter, language, and theme in parallel\n const [highlighter, languageModule, themeModule] = await Promise.all([\n getHighlighterInstance(),\n loadLanguage(lang),\n loadTheme(themeName),\n ]);\n\n // Load into the singleton instance if not already loaded\n if (!highlighter.getLoadedLanguages().includes(lang)) {\n await highlighter.loadLanguage(languageModule);\n }\n if (!highlighter.getLoadedThemes().includes(themeName)) {\n await highlighter.loadTheme(themeModule);\n }\n\n return highlighter.codeToHtml(code, {\n lang,\n theme: themeName,\n });\n};\n\nexport type CodeBlockShikiProps = {\n children: string;\n lang: BundledLanguage;\n isDarkMode?: boolean;\n};\n\nexport const CodeBlockShiki: FC<CodeBlockShikiProps> = ({\n children,\n lang,\n isDarkMode,\n}) => {\n const [html, setHtml] = useState<string | null>(null);\n\n useEffect(() => {\n let isCancelled = false;\n\n highlightCode(children, lang, isDarkMode)\n .then((result) => {\n if (!isCancelled) setHtml(result);\n })\n .catch((error) => {\n console.error('Failed to highlight code:', error);\n if (!isCancelled && html === null) setHtml('');\n });\n\n return () => {\n isCancelled = true;\n };\n }, [children, lang, isDarkMode]);\n\n return (\n <div className=\"min-w-0 max-w-full overflow-auto bg-transparent [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden [&_pre::-webkit-scrollbar]:hidden [&_pre]:[-ms-overflow-style:none] [&_pre]:[scrollbar-width:none]\">\n {html ? (\n // biome-ignore lint/security/noDangerouslySetInnerHtml: Shiki generates safe HTML for code highlighting\n <div dangerouslySetInnerHTML={{ __html: html }} />\n ) : (\n <CodeDefault>{children}</CodeDefault>\n )}\n </div>\n );\n};\n"],"mappings":"yJAWA,MAAM,EAAgB,IAAI,IACpB,EAAa,IAAI,IAGjB,EAAe,K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AU,CACrB,CAAC,CAUF,OAPK,EAAY,oBAAoB,CAAC,SAAS,EAAK,EAClD,MAAM,EAAY,aAAa,EAAe,CAE3C,EAAY,iBAAiB,CAAC,SAAS,EAAU,EACpD,MAAM,EAAY,UAAU,EAAY,CAGnC,EAAY,WAAW,EAAM,CAClC,OACA,MAAO,EACR,CAAC,EASS,GAA2C,CACtD,WACA,OACA,gBACI,CACJ,GAAM,CAAC,EAAM,GAAW,EAAwB,KAAK,CAmBrD,OAjBA,MAAgB,CACd,IAAI,EAAc,GAWlB,OATA,EAAc,EAAU,EAAM,EAAW,CACtC,KAAM,GAAW,CACX,GAAa,EAAQ,EAAO,EACjC,CACD,MAAO,GAAU,CAChB,QAAQ,MAAM,4BAA6B,EAAM,CAC7C,CAAC,GAAe,IAAS,MAAM,EAAQ,GAAG,EAC9C,KAES,CACX,EAAc,KAEf,CAAC,EAAU,EAAM,EAAW,CAAC,CAG9B,EAAC,MAAD,CAAK,UAAU,6OACZ,EAEC,EAAC,MAAD,CAAK,wBAAyB,CAAE,OAAQ,EAAM,CAAI,CAAA,CAElD,EAAC,EAAD,CAAc,WAAuB,CAAA,CAEnC,CAAA"}
@@ -1,2 +1,2 @@
1
- "use client";import{cn as e}from"../../utils/cn.mjs";import{MaxHeightSmoother as t}from"../MaxHeightSmoother/index.mjs";import{createFileTree as n}from"./createFileTree.mjs";import{ChevronRight as r}from"lucide-react";import{useState as i}from"react";import{Fragment as a,jsx as o,jsxs as s}from"react/jsx-runtime";const c=e=>e.join(`/`),l=({filesPaths:n,path:l,subPath:d,onClickFile:f,activeFile:p,prePaths:m,isFile:h})=>{let[g,_]=i(!0),v=m.length+1,y=c([...m.slice(v-1,v),l]),b=c([...m,l]),x=n.map(e=>e.replace(/^\/?/,``)).filter(e=>e.startsWith(y)).map(e=>e.replace(y,``).replace(/^\/?/,``)),S=b===p,C=Array(v).fill(` `).join(``);return s(a,{children:[s(`button`,{className:e(`flex w-full items-start justify-start whitespace-pre text-nowrap px-2 py-1 text-xs transition`,S?`bg-neutral-200 dark:bg-neutral-700`:`cursor-pointer hover:bg-neutral-300 dark:hover:bg-neutral-900`),onClick:()=>{h?f?.(b):_(!g)},children:[o(`span`,{className:e(`whitespace-pre`,h&&`ml-2`),children:C}),!h&&o(r,{className:e(`transition`,g&&`rotate-90 transform`),size:16}),l]},l),d&&o(t,{isHidden:!g,className:`overflow-x-hidden`,children:o(u,{filesPaths:x,activeFile:p,onClickFile:f,prePaths:[...m,l]})})]})},u=({filesPaths:e,activeFile:t,onClickFile:r,prePaths:i=[]})=>o(`div`,{className:`flex size-full flex-col items-start justify-start py-1 text-neutral`,children:n(e).map(({path:n,subPath:a,isFile:s})=>o(l,{isFile:s,subPath:a,path:n,onClickFile:r,activeFile:t,prePaths:i,filesPaths:e},n))});export{u as FileTree};
1
+ "use client";import{cn as e}from"../../utils/cn.mjs";import{MaxHeightSmoother as t}from"../MaxHeightSmoother/index.mjs";import{createFileTree as n}from"./createFileTree.mjs";import{useState as r}from"react";import{ChevronRight as i}from"lucide-react";import{Fragment as a,jsx as o,jsxs as s}from"react/jsx-runtime";const c=e=>e.join(`/`),l=({filesPaths:n,path:l,subPath:d,onClickFile:f,activeFile:p,prePaths:m,isFile:h})=>{let[g,_]=r(!0),v=m.length+1,y=c([...m.slice(v-1,v),l]),b=c([...m,l]),x=n.map(e=>e.replace(/^\/?/,``)).filter(e=>e.startsWith(y)).map(e=>e.replace(y,``).replace(/^\/?/,``)),S=b===p,C=Array(v).fill(` `).join(``);return s(a,{children:[s(`button`,{className:e(`flex w-full items-start justify-start whitespace-pre text-nowrap px-2 py-1 text-xs transition`,S?`bg-neutral-200 dark:bg-neutral-700`:`cursor-pointer hover:bg-neutral-300 dark:hover:bg-neutral-900`),onClick:()=>{h?f?.(b):_(!g)},children:[o(`span`,{className:e(`whitespace-pre`,h&&`ml-2`),children:C}),!h&&o(i,{className:e(`transition`,g&&`rotate-90 transform`),size:16}),l]},l),d&&o(t,{isHidden:!g,className:`overflow-x-hidden`,children:o(u,{filesPaths:x,activeFile:p,onClickFile:f,prePaths:[...m,l]})})]})},u=({filesPaths:e,activeFile:t,onClickFile:r,prePaths:i=[]})=>o(`div`,{className:`flex size-full flex-col items-start justify-start py-1 text-neutral`,children:n(e).map(({path:n,subPath:a,isFile:s})=>o(l,{isFile:s,subPath:a,path:n,onClickFile:r,activeFile:t,prePaths:i,filesPaths:e},n))});export{u as FileTree};
2
2
  //# sourceMappingURL=FileTree.mjs.map
@@ -1,2 +1,2 @@
1
- import{cva as e}from"class-variance-authority";import{jsx as t}from"react/jsx-runtime";const n=(...e)=>e.filter(Boolean).join(` `),r=e([`w-full select-text resize-none text-base shadow-none outline-none`,`transition-all duration-300 md:text-sm`,`ring-0`,`disabled:opacity-50`,`rounded-xl [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-2xl`].join(` `),{variants:{variant:{default:[`text-text`,`bg-neutral-50 dark:bg-neutral-950`,`ring-text/20`,`disabled:ring-0`,`hover:ring-3`,`focus-within:ring-4`,`focus-visible:outline-none focus-visible:ring-4`,`[box-shadow:none] focus:[box-shadow:none]`,`aria-invalid:border-error`].join(` `),invisible:`border-none text-inherit outline-none ring-0`},size:{sm:`px-2 py-2 text-sm md:py-1.5 md:text-xs`,md:`px-2 py-3 md:py-2`,lg:`p-4`},validationStyleEnabled:{disabled:``,enabled:`valid:border-success invalid:border-error`}},defaultVariants:{variant:`default`,size:`md`,validationStyleEnabled:`disabled`}});let i=function(e){return e.DEFAULT=`default`,e.INVISIBLE=`invisible`,e}({}),a=function(e){return e.MD=`md`,e.LG=`lg`,e}({});const o=({validationStyleEnabled:e=!1,variant:i,size:a,className:o,...s})=>t(`input`,{className:n(r({variant:i,size:a,validationStyleEnabled:e?`enabled`:`disabled`}),o),...s});export{o as Input,a as InputSize,i as InputVariant,r as inputVariants};
1
+ import{cva as e}from"class-variance-authority";import{jsx as t}from"react/jsx-runtime";const n=(...e)=>e.filter(Boolean).join(` `),r=e([`w-full select-text resize-none text-base shadow-none outline-none`,`transition-all duration-300 md:text-sm`,`ring-0`,`disabled:opacity-50`,`rounded-xl [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-2xl`].join(` `),{variants:{variant:{default:[`text-text`,`bg-neutral-50 dark:bg-neutral-950`,`ring-text/20`,`disabled:ring-0`,`hover:ring-3`,`focus-within:ring-4`,`focus-visible:outline-none focus-visible:ring-4`,`[box-shadow:none] focus:[box-shadow:none]`,`aria-invalid:border-error`].join(` `),invisible:`border-none text-inherit outline-none ring-0`},size:{sm:`px-2 py-2 text-sm md:py-1.5 md:text-xs`,md:`px-2 py-3 md:py-2`,lg:`p-4`},validationStyleEnabled:{disabled:``,enabled:`valid:border-success invalid:border-error`}},defaultVariants:{variant:`default`,size:`md`,validationStyleEnabled:`disabled`}});let i=function(e){return e.DEFAULT=`default`,e.INVISIBLE=`invisible`,e}({}),a=function(e){return e.MD=`md`,e.LG=`lg`,e}({});const o=({validationStyleEnabled:e=!1,variant:i,size:a,className:o,...s})=>t(`input`,{className:n(r({variant:i,size:a,validationStyleEnabled:e?`enabled`:`disabled`}),o),suppressHydrationWarning:!0,...s});export{o as Input,a as InputSize,i as InputVariant,r as inputVariants};
2
2
  //# sourceMappingURL=Input.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Input.mjs","names":[],"sources":["../../../../src/components/Input/Input.tsx"],"sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority';\nimport type { DetailedHTMLProps, FC, InputHTMLAttributes } from 'react';\n\n// Optional: your own cn helper to merge class names\nconst cn = (...classes: (string | undefined | false | null)[]) =>\n classes.filter(Boolean).join(' ');\n\nexport const inputVariants = cva(\n [\n // base styles\n 'w-full select-text resize-none text-base shadow-none outline-none',\n 'transition-all duration-300 md:text-sm',\n 'ring-0',\n 'disabled:opacity-50',\n\n // Corner shape\n 'rounded-xl [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-2xl',\n ].join(' '),\n {\n variants: {\n variant: {\n default: [\n 'text-text',\n 'bg-neutral-50 dark:bg-neutral-950',\n 'ring-text/20',\n\n // Focus ring\n 'disabled:ring-0',\n 'hover:ring-3',\n 'focus-within:ring-4',\n 'focus-visible:outline-none focus-visible:ring-4',\n\n // Remove any weird box-shadow\n '[box-shadow:none] focus:[box-shadow:none]',\n\n // aria-invalid border color\n 'aria-invalid:border-error',\n ].join(' '),\n invisible: 'border-none text-inherit outline-none ring-0',\n },\n size: {\n sm: 'px-2 py-2 text-sm md:py-1.5 md:text-xs',\n md: 'px-2 py-3 md:py-2',\n lg: 'p-4',\n },\n validationStyleEnabled: {\n disabled: '',\n enabled: 'valid:border-success invalid:border-error',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'md',\n validationStyleEnabled: 'disabled',\n },\n }\n);\n\nexport enum InputVariant {\n DEFAULT = 'default',\n INVISIBLE = 'invisible',\n}\n\nexport enum InputSize {\n MD = 'md',\n LG = 'lg',\n}\n\nexport type InputProps = Omit<\n DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>,\n 'size'\n> & {\n validationStyleEnabled?: boolean;\n} & Omit<VariantProps<typeof inputVariants>, 'validationStyleEnabled'>;\n\nexport const Input: FC<InputProps> = ({\n validationStyleEnabled = false,\n variant,\n size,\n className,\n ...props\n}) => (\n <input\n className={cn(\n inputVariants({\n variant,\n size,\n validationStyleEnabled: validationStyleEnabled ? 'enabled' : 'disabled',\n }),\n className\n )}\n {...props}\n />\n);\n"],"mappings":"uFAIA,MAAM,GAAM,GAAG,IACb,EAAQ,OAAO,QAAQ,CAAC,KAAK,IAAI,CAEtB,EAAgB,EAC3B,CAEE,oEACA,yCACA,SACA,sBAGA,kFACD,CAAC,KAAK,IAAI,CACX,CACE,SAAU,CACR,QAAS,CACP,QAAS,CACP,YACA,oCACA,eAGA,kBACA,eACA,sBACA,kDAGA,4CAGA,4BACD,CAAC,KAAK,IAAI,CACX,UAAW,+CACZ,CACD,KAAM,CACJ,GAAI,yCACJ,GAAI,oBACJ,GAAI,MACL,CACD,uBAAwB,CACtB,SAAU,GACV,QAAS,4CACV,CACF,CACD,gBAAiB,CACf,QAAS,UACT,KAAM,KACN,uBAAwB,WACzB,CACF,CACF,CAED,IAAY,EAAL,SAAA,EAAA,OACL,GAAA,QAAA,UACA,EAAA,UAAA,kBACD,CAEW,EAAL,SAAA,EAAA,OACL,GAAA,GAAA,KACA,EAAA,GAAA,WACD,CASD,MAAa,GAAyB,CACpC,yBAAyB,GACzB,UACA,OACA,YACA,GAAG,KAEH,EAAC,QAAD,CACE,UAAW,EACT,EAAc,CACZ,UACA,OACA,uBAAwB,EAAyB,UAAY,WAC9D,CAAC,CACF,EACD,CACD,GAAI,EACJ,CAAA"}
1
+ {"version":3,"file":"Input.mjs","names":[],"sources":["../../../../src/components/Input/Input.tsx"],"sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority';\nimport type { DetailedHTMLProps, FC, InputHTMLAttributes } from 'react';\n\n// Optional: your own cn helper to merge class names\nconst cn = (...classes: (string | undefined | false | null)[]) =>\n classes.filter(Boolean).join(' ');\n\nexport const inputVariants = cva(\n [\n // base styles\n 'w-full select-text resize-none text-base shadow-none outline-none',\n 'transition-all duration-300 md:text-sm',\n 'ring-0',\n 'disabled:opacity-50',\n\n // Corner shape\n 'rounded-xl [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-2xl',\n ].join(' '),\n {\n variants: {\n variant: {\n default: [\n 'text-text',\n 'bg-neutral-50 dark:bg-neutral-950',\n 'ring-text/20',\n\n // Focus ring\n 'disabled:ring-0',\n 'hover:ring-3',\n 'focus-within:ring-4',\n 'focus-visible:outline-none focus-visible:ring-4',\n\n // Remove any weird box-shadow\n '[box-shadow:none] focus:[box-shadow:none]',\n\n // aria-invalid border color\n 'aria-invalid:border-error',\n ].join(' '),\n invisible: 'border-none text-inherit outline-none ring-0',\n },\n size: {\n sm: 'px-2 py-2 text-sm md:py-1.5 md:text-xs',\n md: 'px-2 py-3 md:py-2',\n lg: 'p-4',\n },\n validationStyleEnabled: {\n disabled: '',\n enabled: 'valid:border-success invalid:border-error',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'md',\n validationStyleEnabled: 'disabled',\n },\n }\n);\n\nexport enum InputVariant {\n DEFAULT = 'default',\n INVISIBLE = 'invisible',\n}\n\nexport enum InputSize {\n MD = 'md',\n LG = 'lg',\n}\n\nexport type InputProps = Omit<\n DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>,\n 'size'\n> & {\n validationStyleEnabled?: boolean;\n} & Omit<VariantProps<typeof inputVariants>, 'validationStyleEnabled'>;\n\nexport const Input: FC<InputProps> = ({\n validationStyleEnabled = false,\n variant,\n size,\n className,\n ...props\n}) => (\n <input\n className={cn(\n inputVariants({\n variant,\n size,\n validationStyleEnabled: validationStyleEnabled ? 'enabled' : 'disabled',\n }),\n className\n )}\n suppressHydrationWarning\n {...props}\n />\n);\n"],"mappings":"uFAIA,MAAM,GAAM,GAAG,IACb,EAAQ,OAAO,QAAQ,CAAC,KAAK,IAAI,CAEtB,EAAgB,EAC3B,CAEE,oEACA,yCACA,SACA,sBAGA,kFACD,CAAC,KAAK,IAAI,CACX,CACE,SAAU,CACR,QAAS,CACP,QAAS,CACP,YACA,oCACA,eAGA,kBACA,eACA,sBACA,kDAGA,4CAGA,4BACD,CAAC,KAAK,IAAI,CACX,UAAW,+CACZ,CACD,KAAM,CACJ,GAAI,yCACJ,GAAI,oBACJ,GAAI,MACL,CACD,uBAAwB,CACtB,SAAU,GACV,QAAS,4CACV,CACF,CACD,gBAAiB,CACf,QAAS,UACT,KAAM,KACN,uBAAwB,WACzB,CACF,CACF,CAED,IAAY,EAAL,SAAA,EAAA,OACL,GAAA,QAAA,UACA,EAAA,UAAA,kBACD,CAEW,EAAL,SAAA,EAAA,OACL,GAAA,GAAA,KACA,EAAA,GAAA,WACD,CASD,MAAa,GAAyB,CACpC,yBAAyB,GACzB,UACA,OACA,YACA,GAAG,KAEH,EAAC,QAAD,CACE,UAAW,EACT,EAAc,CACZ,UACA,OACA,uBAAwB,EAAyB,UAAY,WAC9D,CAAC,CACF,EACD,CACD,yBAAA,GACA,GAAI,EACJ,CAAA"}
@@ -1,2 +1,2 @@
1
- "use client";import{Input as e}from"./Input.mjs";import{EyeIcon as t,EyeOffIcon as n}from"lucide-react";import{useState as r}from"react";import{jsx as i,jsxs as a}from"react/jsx-runtime";const o=o=>{let[s,c]=r(!1),l=e=>{e.preventDefault(),e.stopPropagation(),c(e=>!e)},u=s?t:n;return a(`div`,{className:`relative`,children:[i(e,{...o,"aria-label":`password`,type:s?`text`:`password`}),i(`button`,{"data-testid":`eye-icon`,type:`button`,className:`absolute right-2 h-full flex-row items-center`,onClick:l,"aria-label":s?`Hide password`:`Show password`,children:i(u,{className:`mr-2 inline-block cursor-pointer text-neutral`,size:20})})]})};export{o as InputPassword};
1
+ "use client";import{Input as e}from"./Input.mjs";import{useState as t}from"react";import{EyeIcon as n,EyeOffIcon as r}from"lucide-react";import{jsx as i,jsxs as a}from"react/jsx-runtime";const o=o=>{let[s,c]=t(!1),l=e=>{e.preventDefault(),e.stopPropagation(),c(e=>!e)},u=s?n:r;return a(`div`,{className:`relative`,children:[i(e,{...o,"aria-label":`password`,type:s?`text`:`password`}),i(`button`,{"data-testid":`eye-icon`,type:`button`,className:`absolute right-2 h-full flex-row items-center`,onClick:l,"aria-label":s?`Hide password`:`Show password`,children:i(u,{className:`mr-2 inline-block cursor-pointer text-neutral`,size:20})})]})};export{o as InputPassword};
2
2
  //# sourceMappingURL=InputPassword.mjs.map
@@ -1,4 +1,4 @@
1
- "use client";import{cn as e}from"../../utils/cn.mjs";import{Button as t}from"../Button/Button.mjs";import{MinusIcon as n}from"lucide-react";import{createContext as r,useContext as i,useEffect as a,useRef as o,useState as s}from"react";import{cva as c}from"class-variance-authority";import{Fragment as l,jsx as u,jsxs as d}from"react/jsx-runtime";const f=e=>[setTimeout(e,0),setTimeout(e,10),setTimeout(e,50)],p=(e,t)=>{try{e.insertRule(t)}catch{console.error(`input-otp could not insert CSS rule:`,t)}},m=[`[data-lastpass-icon-root]`,`com-1password-button`,`[data-dashlanecreated]`,`[style$="2147483647 !important;"]`].join(`,`),h=({containerRef:e,inputRef:t,pushPasswordManagerStrategy:n,isFocused:r})=>{let[i,o]=s(!1),[c,l]=s(!1),[u,d]=s(!1),f=n===`none`?!1:(n===`increase-width`||n===`experimental-no-flickering`)&&i&&c,p=()=>{let r=e.current,i=t.current;if(!r||!i||u||n===`none`)return;let a=r,s=a.getBoundingClientRect().left+a.offsetWidth,c=a.getBoundingClientRect().top+a.offsetHeight/2,l=s-18,f=c;document.querySelectorAll(m).length===0&&document.elementFromPoint(l,f)===r||(o(!0),d(!0))};return a(()=>{let t=e.current;if(!t||n===`none`)return;let r=()=>{l(window.innerWidth-t.getBoundingClientRect().right>=40)};r();let i=setInterval(r,1e3);return()=>{clearInterval(i)}},[e,n]),a(()=>{let e=r||document.activeElement===t.current;if(n===`none`||!e)return;let i=setTimeout(p,0),a=setTimeout(p,2e3),o=setTimeout(p,5e3),s=setTimeout(()=>{d(!0)},6e3);return()=>{clearTimeout(i),clearTimeout(a),clearTimeout(o),clearTimeout(s)}},[t,r,n]),{hasPWMBadge:i,willPushPWMBadge:f,PWM_BADGE_SPACE_WIDTH:`40px`}},g=e=>{let t=o(void 0);return a(()=>{t.current=e}),t.current},_=r({}),v=({value:t,onChange:n,maxLength:r,pattern:i,placeholder:c,inputMode:m=`numeric`,onComplete:v,onActiveSlotChange:y,pushPasswordManagerStrategy:b=`increase-width`,pasteTransformer:x,containerClassName:S,noScriptCSSFallback:C=`
1
+ "use client";import{cn as e}from"../../utils/cn.mjs";import{Button as t}from"../Button/Button.mjs";import{createContext as n,useContext as r,useEffect as i,useRef as a,useState as o}from"react";import{cva as s}from"class-variance-authority";import{MinusIcon as c}from"lucide-react";import{Fragment as l,jsx as u,jsxs as d}from"react/jsx-runtime";const f=e=>[setTimeout(e,0),setTimeout(e,10),setTimeout(e,50)],p=(e,t)=>{try{e.insertRule(t)}catch{console.error(`input-otp could not insert CSS rule:`,t)}},m=[`[data-lastpass-icon-root]`,`com-1password-button`,`[data-dashlanecreated]`,`[style$="2147483647 !important;"]`].join(`,`),h=({containerRef:e,inputRef:t,pushPasswordManagerStrategy:n,isFocused:r})=>{let[a,s]=o(!1),[c,l]=o(!1),[u,d]=o(!1),f=n===`none`?!1:(n===`increase-width`||n===`experimental-no-flickering`)&&a&&c,p=()=>{let r=e.current,i=t.current;if(!r||!i||u||n===`none`)return;let a=r,o=a.getBoundingClientRect().left+a.offsetWidth,c=a.getBoundingClientRect().top+a.offsetHeight/2,l=o-18,f=c;document.querySelectorAll(m).length===0&&document.elementFromPoint(l,f)===r||(s(!0),d(!0))};return i(()=>{let t=e.current;if(!t||n===`none`)return;let r=()=>{l(window.innerWidth-t.getBoundingClientRect().right>=40)};r();let i=setInterval(r,1e3);return()=>{clearInterval(i)}},[e,n]),i(()=>{let e=r||document.activeElement===t.current;if(n===`none`||!e)return;let i=setTimeout(p,0),a=setTimeout(p,2e3),o=setTimeout(p,5e3),s=setTimeout(()=>{d(!0)},6e3);return()=>{clearTimeout(i),clearTimeout(a),clearTimeout(o),clearTimeout(s)}},[t,r,n]),{hasPWMBadge:a,willPushPWMBadge:f,PWM_BADGE_SPACE_WIDTH:`40px`}},g=e=>{let t=a(void 0);return i(()=>{t.current=e}),t.current},_=n({}),v=({value:t,onChange:n,maxLength:r,pattern:s,placeholder:c,inputMode:m=`numeric`,onComplete:v,onActiveSlotChange:y,pushPasswordManagerStrategy:b=`increase-width`,pasteTransformer:x,containerClassName:S,noScriptCSSFallback:C=`
2
2
  [data-input-otp] {
3
3
  --nojs-bg: white !important;
4
4
  --nojs-fg: black !important;
@@ -17,5 +17,5 @@
17
17
  --nojs-bg: black !important;
18
18
  --nojs-fg: white !important;
19
19
  }
20
- }`,render:w,children:T,...E})=>{let[D,ee]=s(typeof E.defaultValue==`string`?E.defaultValue:``),O=t??D,k=g(O),A=e=>{n?.(e),ee(e)},j=i===void 0?null:typeof i==`string`?new RegExp(i):i,M=o(null),N=o(null),P=o({value:O,onChange:A,isIOS:typeof window<`u`&&window?.CSS?.supports?.(`-webkit-touch-callout`,`none`)}),F=o({prev:[M.current?.selectionStart??null,M.current?.selectionEnd??null,M.current?.selectionDirection??`none`]});a(()=>{let e=M.current,t=N.current;if(!e||!t)return;P.current.value!==e.value&&P.current.onChange(e.value),F.current.prev=[e.selectionStart,e.selectionEnd,e.selectionDirection??`none`];let n=()=>{if(document.activeElement!==e){V(null),U(null),G(null);return}let t=e.selectionStart,n=e.selectionEnd,r=e.selectionDirection,i=e.maxLength,a=e.value,o=F.current.prev,s=-1,c=-1,l=r??`none`;if(a.length!==0&&t!==null&&n!==null){let e=t===n,r=t===a.length&&a.length<i;if(e&&!r){let e=t;if(e===0)s=0,c=1,l=`forward`;else if(e===i)s=e-1,c=e,l=`backward`;else if(i>1&&a.length>1){let t=0;if(o[0]!==null&&o[1]!==null){l=e<o[1]?`backward`:`forward`;let n=o[0]===o[1]&&o[0]<i;l===`backward`&&!n&&(t=-1)}s=t+e,c=t+e+1}}s!==-1&&c!==-1&&s!==c&&M.current?.setSelectionRange(s,c,l)}let u=s===-1?t:s,d=c===-1?n:c,f=l;G(t!==null&&n!==null?t===n?t:u:null),V(u),U(d),F.current.prev=[u,d,f]};if(document.addEventListener(`selectionchange`,n,{capture:!0}),n(),document.activeElement===e&&z(!0),!document.getElementById(`input-otp-style`)){let e=document.createElement(`style`);if(e.id=`input-otp-style`,document.head.appendChild(e),e.sheet){let t=`background: transparent !important; color: transparent !important; border-color: transparent !important; opacity: 0 !important; box-shadow: none !important; -webkit-box-shadow: none !important; -webkit-text-fill-color: transparent !important;`;p(e.sheet,`[data-input-otp]::selection { background: transparent !important; color: transparent !important; }`),p(e.sheet,`[data-input-otp]:autofill { ${t} }`),p(e.sheet,`[data-input-otp]:-webkit-autofill { ${t} }`),p(e.sheet,`@supports (-webkit-touch-callout: none) { [data-input-otp] { letter-spacing: -.6em !important; font-weight: 100 !important; font-stretch: ultra-condensed; font-optical-sizing: none !important; left: -1px !important; right: 1px !important; } }`),p(e.sheet,`[data-input-otp] + * { pointer-events: all !important; }`)}}let r=()=>{t&&t.style.setProperty(`--root-height`,`${e.clientHeight}px`)};r();let i=new ResizeObserver(r);return i.observe(e),()=>{document.removeEventListener(`selectionchange`,n,{capture:!0}),i.disconnect()}},[]);let[I,L]=s(!1),[R,z]=s(!1),[B,V]=s(null),[H,U]=s(null),[W,G]=s(null);a(()=>{f(()=>{M.current?.dispatchEvent(new Event(`input`));let e=M.current?.selectionStart??null,t=M.current?.selectionEnd??null,n=M.current?.selectionDirection??`none`;e!==null&&t!==null&&(V(e),U(t),G(e),F.current.prev=[e,t,n])})},[O,R]),a(()=>{k!==void 0&&O!==k&&k.length<r&&O.length===r&&v?.(O)},[r,v,k,O]);let K=o(null);a(()=>{let e=R&&W!==null?W:null;e!==K.current&&(K.current=e,y?.(e))},[R,W,y]);let q=h({containerRef:N,inputRef:M,pushPasswordManagerStrategy:b,isFocused:R}),J=e=>{let t=e.currentTarget.value.slice(0,r);if(t.length>0&&j&&!j.test(t)){e.preventDefault();return}typeof k==`string`&&t.length<k.length&&document.dispatchEvent(new Event(`selectionchange`)),A(t)},Y=()=>{if(M.current){let e=Math.min(M.current.value.length,r-1),t=M.current.value.length;M.current?.setSelectionRange(e,t),V(e),U(t)}z(!0)},X=e=>{let t=M.current;if(!x&&(!P.current.isIOS||!e.clipboardData||!t))return;let n=e.clipboardData.getData(`text/plain`),i=x?x(n):n;e.preventDefault();let a=M.current?.selectionStart,o=M.current?.selectionEnd,s=(a===o?O.slice(0,a??0)+i+O.slice(a??0):O.slice(0,a??0)+i+O.slice(o??0)).slice(0,r);if(!(s.length>0&&j&&!j.test(s))&&t){t.value=s,A(s);let e=Math.min(s.length,r-1),n=s.length;t.setSelectionRange(e,n),V(e),U(n)}},Z={width:q.willPushPWMBadge?`calc(100% + ${q.PWM_BADGE_SPACE_WIDTH})`:`100%`,clipPath:q.willPushPWMBadge?`inset(0 ${q.PWM_BADGE_SPACE_WIDTH} 0 0)`:void 0,fontSize:`var(--root-height)`},Q=u(`input`,{autoComplete:E.autoComplete||`one-time-code`,...E,"data-input-otp":!0,"data-input-otp-placeholder-shown":O.length===0||void 0,"data-input-otp-mss":B,"data-input-otp-mse":H,inputMode:m,pattern:j?.source,"aria-placeholder":c,className:`pointer-events-auto absolute inset-0 -z-10 flex h-full border-0 border-transparent bg-transparent text-center font-mono text-transparent tabular-nums leading-none tracking-[-.5em] caret-transparent opacity-100 shadow-none outline-none`,style:Z,maxLength:r,value:O,ref:M,onPaste:e=>{X(e),E.onPaste?.(e)},onChange:J,onMouseOver:e=>{L(!0),E.onMouseOver?.(e)},onMouseLeave:e=>{L(!1),E.onMouseLeave?.(e)},onKeyDown:e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&requestAnimationFrame(()=>{let e=M.current;if(e&&document.activeElement===e){let t=e.selectionStart,n=e.selectionEnd;t!==null&&n!==null&&G(t)}}),E.onKeyDown?.(e)},onFocus:e=>{Y(),E.onFocus?.(e)},onBlur:e=>{z(!1),E.onBlur?.(e)}}),$={slots:Array.from({length:r}).map((e,t)=>{let n=R&&B!==null&&H!==null&&(B===H&&t===B||t>=B&&t<H),r=O[t]===void 0?null:O[t];return{char:r,placeholderChar:O[0]===void 0?c?.[t]??null:null,isActive:n,hasFakeCaret:n&&r===null}}),isFocused:R,isHovering:!E.disabled&&I,setSelection:e=>{let t=M.current;if(!t||E.disabled)return;let n=Math.max(0,Math.min(e,r-1));document.activeElement!==t&&t.focus();let i=O[n]!==void 0,a=n,o=i?n+1:n;t.setSelectionRange(a,o),V(a),U(o),z(!0)}},te=w===void 0?u(_.Provider,{value:$,children:T}):w($);return d(l,{children:[C!==null&&u(`noscript`,{children:u(`style`,{children:C})}),d(`div`,{ref:N,className:e(`relative`,E.disabled?`cursor-default`:`cursor-text`,S),children:[te,u(`div`,{className:`absolute inset-0`,children:Q})]})]})},y=c(`block text-center`,{variants:{size:{sm:`h-4 w-3 text-sm`,md:`h-5 w-4 text-base`,lg:`h-6 w-5 text-lg`,xl:`h-7 w-6 text-xl`}},defaultVariants:{size:`md`}}),b=({className:t,render:n,...r})=>u(v,{containerClassName:`relative flex items-center gap-2 has-disabled:opacity-50`,className:e(`disabled:cursor-not-allowed`,t),render:n,...r}),x=({className:t,...n})=>u(`div`,{className:e(`z-10 flex items-center gap-3`,t),...n}),S=({index:n,className:r,onClick:a,onKeyDown:o,...s})=>{let c=i(_),{char:l,isActive:d}=c?.slots[n]??{},{setSelection:f}=c??{};return u(t,{isSelected:d,variant:`input`,color:`custom`,tabIndex:-1,className:e(`relative z-10 px-2!`,d&&`ring-4!`,r),onClick:e=>{f?.(n),a?.(e)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),f?.(n)),o?.(e)},label:null,...s,children:u(`span`,{className:`relative z-10 flex h-6 w-4 items-center justify-center`,children:l})})},C=e=>u(`div`,{"aria-hidden":!0,className:`z-0 table h-0.5 w-3 rounded-full bg-border text-text/50`,...e,children:u(n,{})}),w=e=>u(`div`,{"data-indicator":!0,className:`absolute top-0 z-0 h-full w-auto rounded-xl bg-text/20 ring-4 ring-text/20 transition-[left,width] duration-300 ease-in-out [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-2xl motion-reduce:transition-none`,...e});export{w as InputIndicator,b as InputOTP,x as InputOTPGroup,C as InputOTPSeparator,S as InputOTPSlot,v as OTPInput,_ as OTPInputContext,y as inputSlotVariants,h as usePasswordManagerBadge,g as usePrevious};
20
+ }`,render:w,children:T,...E})=>{let[D,ee]=o(typeof E.defaultValue==`string`?E.defaultValue:``),O=t??D,k=g(O),A=e=>{n?.(e),ee(e)},j=s===void 0?null:typeof s==`string`?new RegExp(s):s,M=a(null),N=a(null),P=a({value:O,onChange:A,isIOS:typeof window<`u`&&window?.CSS?.supports?.(`-webkit-touch-callout`,`none`)}),F=a({prev:[M.current?.selectionStart??null,M.current?.selectionEnd??null,M.current?.selectionDirection??`none`]});i(()=>{let e=M.current,t=N.current;if(!e||!t)return;P.current.value!==e.value&&P.current.onChange(e.value),F.current.prev=[e.selectionStart,e.selectionEnd,e.selectionDirection??`none`];let n=()=>{if(document.activeElement!==e){V(null),U(null),G(null);return}let t=e.selectionStart,n=e.selectionEnd,r=e.selectionDirection,i=e.maxLength,a=e.value,o=F.current.prev,s=-1,c=-1,l=r??`none`;if(a.length!==0&&t!==null&&n!==null){let e=t===n,r=t===a.length&&a.length<i;if(e&&!r){let e=t;if(e===0)s=0,c=1,l=`forward`;else if(e===i)s=e-1,c=e,l=`backward`;else if(i>1&&a.length>1){let t=0;if(o[0]!==null&&o[1]!==null){l=e<o[1]?`backward`:`forward`;let n=o[0]===o[1]&&o[0]<i;l===`backward`&&!n&&(t=-1)}s=t+e,c=t+e+1}}s!==-1&&c!==-1&&s!==c&&M.current?.setSelectionRange(s,c,l)}let u=s===-1?t:s,d=c===-1?n:c,f=l;G(t!==null&&n!==null?t===n?t:u:null),V(u),U(d),F.current.prev=[u,d,f]};if(document.addEventListener(`selectionchange`,n,{capture:!0}),n(),document.activeElement===e&&z(!0),!document.getElementById(`input-otp-style`)){let e=document.createElement(`style`);if(e.id=`input-otp-style`,document.head.appendChild(e),e.sheet){let t=`background: transparent !important; color: transparent !important; border-color: transparent !important; opacity: 0 !important; box-shadow: none !important; -webkit-box-shadow: none !important; -webkit-text-fill-color: transparent !important;`;p(e.sheet,`[data-input-otp]::selection { background: transparent !important; color: transparent !important; }`),p(e.sheet,`[data-input-otp]:autofill { ${t} }`),p(e.sheet,`[data-input-otp]:-webkit-autofill { ${t} }`),p(e.sheet,`@supports (-webkit-touch-callout: none) { [data-input-otp] { letter-spacing: -.6em !important; font-weight: 100 !important; font-stretch: ultra-condensed; font-optical-sizing: none !important; left: -1px !important; right: 1px !important; } }`),p(e.sheet,`[data-input-otp] + * { pointer-events: all !important; }`)}}let r=()=>{t&&t.style.setProperty(`--root-height`,`${e.clientHeight}px`)};r();let i=new ResizeObserver(r);return i.observe(e),()=>{document.removeEventListener(`selectionchange`,n,{capture:!0}),i.disconnect()}},[]);let[I,L]=o(!1),[R,z]=o(!1),[B,V]=o(null),[H,U]=o(null),[W,G]=o(null);i(()=>{f(()=>{M.current?.dispatchEvent(new Event(`input`));let e=M.current?.selectionStart??null,t=M.current?.selectionEnd??null,n=M.current?.selectionDirection??`none`;e!==null&&t!==null&&(V(e),U(t),G(e),F.current.prev=[e,t,n])})},[O,R]),i(()=>{k!==void 0&&O!==k&&k.length<r&&O.length===r&&v?.(O)},[r,v,k,O]);let K=a(null);i(()=>{let e=R&&W!==null?W:null;e!==K.current&&(K.current=e,y?.(e))},[R,W,y]);let q=h({containerRef:N,inputRef:M,pushPasswordManagerStrategy:b,isFocused:R}),J=e=>{let t=e.currentTarget.value.slice(0,r);if(t.length>0&&j&&!j.test(t)){e.preventDefault();return}typeof k==`string`&&t.length<k.length&&document.dispatchEvent(new Event(`selectionchange`)),A(t)},Y=()=>{if(M.current){let e=Math.min(M.current.value.length,r-1),t=M.current.value.length;M.current?.setSelectionRange(e,t),V(e),U(t)}z(!0)},X=e=>{let t=M.current;if(!x&&(!P.current.isIOS||!e.clipboardData||!t))return;let n=e.clipboardData.getData(`text/plain`),i=x?x(n):n;e.preventDefault();let a=M.current?.selectionStart,o=M.current?.selectionEnd,s=(a===o?O.slice(0,a??0)+i+O.slice(a??0):O.slice(0,a??0)+i+O.slice(o??0)).slice(0,r);if(!(s.length>0&&j&&!j.test(s))&&t){t.value=s,A(s);let e=Math.min(s.length,r-1),n=s.length;t.setSelectionRange(e,n),V(e),U(n)}},Z={width:q.willPushPWMBadge?`calc(100% + ${q.PWM_BADGE_SPACE_WIDTH})`:`100%`,clipPath:q.willPushPWMBadge?`inset(0 ${q.PWM_BADGE_SPACE_WIDTH} 0 0)`:void 0,fontSize:`var(--root-height)`},Q=u(`input`,{autoComplete:E.autoComplete||`one-time-code`,...E,"data-input-otp":!0,"data-input-otp-placeholder-shown":O.length===0||void 0,"data-input-otp-mss":B,"data-input-otp-mse":H,inputMode:m,pattern:j?.source,"aria-placeholder":c,className:`pointer-events-auto absolute inset-0 -z-10 flex h-full border-0 border-transparent bg-transparent text-center font-mono text-transparent tabular-nums leading-none tracking-[-.5em] caret-transparent opacity-100 shadow-none outline-none`,style:Z,maxLength:r,value:O,ref:M,onPaste:e=>{X(e),E.onPaste?.(e)},onChange:J,onMouseOver:e=>{L(!0),E.onMouseOver?.(e)},onMouseLeave:e=>{L(!1),E.onMouseLeave?.(e)},onKeyDown:e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&requestAnimationFrame(()=>{let e=M.current;if(e&&document.activeElement===e){let t=e.selectionStart,n=e.selectionEnd;t!==null&&n!==null&&G(t)}}),E.onKeyDown?.(e)},onFocus:e=>{Y(),E.onFocus?.(e)},onBlur:e=>{z(!1),E.onBlur?.(e)}}),$={slots:Array.from({length:r}).map((e,t)=>{let n=R&&B!==null&&H!==null&&(B===H&&t===B||t>=B&&t<H),r=O[t]===void 0?null:O[t];return{char:r,placeholderChar:O[0]===void 0?c?.[t]??null:null,isActive:n,hasFakeCaret:n&&r===null}}),isFocused:R,isHovering:!E.disabled&&I,setSelection:e=>{let t=M.current;if(!t||E.disabled)return;let n=Math.max(0,Math.min(e,r-1));document.activeElement!==t&&t.focus();let i=O[n]!==void 0,a=n,o=i?n+1:n;t.setSelectionRange(a,o),V(a),U(o),z(!0)}},te=w===void 0?u(_.Provider,{value:$,children:T}):w($);return d(l,{children:[C!==null&&u(`noscript`,{children:u(`style`,{children:C})}),d(`div`,{ref:N,className:e(`relative`,E.disabled?`cursor-default`:`cursor-text`,S),children:[te,u(`div`,{className:`absolute inset-0`,children:Q})]})]})},y=s(`block text-center`,{variants:{size:{sm:`h-4 w-3 text-sm`,md:`h-5 w-4 text-base`,lg:`h-6 w-5 text-lg`,xl:`h-7 w-6 text-xl`}},defaultVariants:{size:`md`}}),b=({className:t,render:n,...r})=>u(v,{containerClassName:`relative flex items-center gap-2 has-disabled:opacity-50`,className:e(`disabled:cursor-not-allowed`,t),render:n,...r}),x=({className:t,...n})=>u(`div`,{className:e(`z-10 flex items-center gap-3`,t),...n}),S=({index:n,className:i,onClick:a,onKeyDown:o,...s})=>{let c=r(_),{char:l,isActive:d}=c?.slots[n]??{},{setSelection:f}=c??{};return u(t,{isSelected:d,variant:`input`,color:`custom`,tabIndex:-1,className:e(`relative z-10 px-2!`,d&&`ring-4!`,i),onClick:e=>{f?.(n),a?.(e)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),f?.(n)),o?.(e)},label:null,...s,children:u(`span`,{className:`relative z-10 flex h-6 w-4 items-center justify-center`,children:l})})},C=e=>u(`div`,{"aria-hidden":!0,className:`z-0 table h-0.5 w-3 rounded-full bg-border text-text/50`,...e,children:u(c,{})}),w=e=>u(`div`,{"data-indicator":!0,className:`absolute top-0 z-0 h-full w-auto rounded-xl bg-text/20 ring-4 ring-text/20 transition-[left,width] duration-300 ease-in-out [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-2xl motion-reduce:transition-none`,...e});export{w as InputIndicator,b as InputOTP,x as InputOTPGroup,C as InputOTPSeparator,S as InputOTPSlot,v as OTPInput,_ as OTPInputContext,y as inputSlotVariants,h as usePasswordManagerBadge,g as usePrevious};
21
21
  //# sourceMappingURL=OTPInput.mjs.map
@@ -1,2 +1,2 @@
1
- import{cn as e}from"../../utils/cn.mjs";import{jsx as t,jsxs as n}from"react/jsx-runtime";const r=({htmlFor:r,required:i=!1,disabled:a=!1,className:o,children:s,...c})=>n(`label`,{className:e(`select-none font-medium text-sm leading-none`,`peer-disabled:cursor-not-allowed peer-disabled:opacity-70`,a&&`cursor-not-allowed text-muted-foreground opacity-70`,o),htmlFor:r,...c,children:[s,i&&t(`span`,{className:`ml-1 text-destructive`,"aria-label":`required`,title:`This field is required`,children:`*`})]});export{r as Label};
1
+ import{cn as e}from"../../utils/cn.mjs";import{jsx as t,jsxs as n}from"react/jsx-runtime";const r=({htmlFor:r,required:i=!1,disabled:a=!1,className:o,children:s,...c})=>n(`label`,{className:e(`select-none font-medium text-sm leading-none`,`peer-disabled:cursor-not-allowed peer-disabled:opacity-70`,a&&`cursor-not-allowed text-muted-foreground opacity-70`,o),htmlFor:r,suppressHydrationWarning:!0,...c,children:[s,i&&t(`span`,{className:`ml-1 text-destructive`,"aria-label":`required`,title:`This field is required`,children:`*`})]});export{r as Label};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/components/Label/index.tsx"],"sourcesContent":["import { cn } from '@utils/cn';\nimport type { FC, LabelHTMLAttributes } from 'react';\n\n/**\n * Props for the Label component\n */\nexport interface LabelProps extends LabelHTMLAttributes<HTMLLabelElement> {\n /**\n * The ID of the form control this label is associated with.\n * This creates the accessible relationship between the label and its control.\n * @example \"email-input\"\n * @example \"password-field\"\n */\n htmlFor?: string;\n\n /**\n * Whether the associated form control is required.\n * Adds visual indicator and updates ARIA attributes.\n * @default false\n */\n required?: boolean;\n\n /**\n * Whether the associated form control is disabled.\n * Updates styling to indicate disabled state.\n * @default false\n */\n disabled?: boolean;\n\n /**\n * Additional CSS classes for custom styling\n * @example \"text-red-600 font-bold\"\n */\n className?: string;\n}\n\n/**\n * Label Component\n *\n * A form label component that provides accessible labeling for form controls.\n * Establishes proper relationships between labels and their associated form elements\n * with visual indicators for required and disabled states.\n *\n * @example\n * ```tsx\n * // Basic usage\n * <Label htmlFor=\"email\">Email Address</Label>\n * <input id=\"email\" type=\"email\" />\n *\n * // Required field\n * <Label htmlFor=\"password\" required>Password</Label>\n * <input id=\"password\" type=\"password\" required />\n *\n * // Disabled field\n * <Label htmlFor=\"disabled-field\" disabled>Disabled Field</Label>\n * <input id=\"disabled-field\" type=\"text\" disabled />\n *\n * // With custom styling\n * <Label htmlFor=\"custom\" className=\"text-blue-600 font-semibold\">\n * Custom Styled Label\n * </Label>\n * ```\n *\n * @component\n * @accessibility\n * - Uses semantic HTML <label> element\n * - Properly associates with form controls via htmlFor/id relationship\n * - Supports click-to-focus behavior automatically\n * - Visual indicators for required and disabled states\n * - Screen reader compatible with proper ARIA relationships\n */\nexport const Label: FC<LabelProps> = ({\n htmlFor,\n required = false,\n disabled = false,\n className,\n children,\n ...props\n}) => (\n <label\n className={cn(\n 'select-none font-medium text-sm leading-none',\n 'peer-disabled:cursor-not-allowed peer-disabled:opacity-70',\n disabled && 'cursor-not-allowed text-muted-foreground opacity-70',\n className\n )}\n htmlFor={htmlFor}\n {...props}\n >\n {children}\n {required && (\n <span\n className=\"ml-1 text-destructive\"\n aria-label=\"required\"\n title=\"This field is required\"\n >\n *\n </span>\n )}\n </label>\n);\n"],"mappings":"0FAuEA,MAAa,GAAyB,CACpC,UACA,WAAW,GACX,WAAW,GACX,YACA,WACA,GAAG,KAEH,EAAC,QAAD,CACE,UAAW,EACT,+CACA,4DACA,GAAY,sDACZ,EACD,CACQ,UACT,GAAI,WARN,CAUG,EACA,GACC,EAAC,OAAD,CACE,UAAU,wBACV,aAAW,WACX,MAAM,kCACP,IAEM,CAAA,CAEH"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/components/Label/index.tsx"],"sourcesContent":["import { cn } from '@utils/cn';\nimport type { FC, LabelHTMLAttributes } from 'react';\n\n/**\n * Props for the Label component\n */\nexport interface LabelProps extends LabelHTMLAttributes<HTMLLabelElement> {\n /**\n * The ID of the form control this label is associated with.\n * This creates the accessible relationship between the label and its control.\n * @example \"email-input\"\n * @example \"password-field\"\n */\n htmlFor?: string;\n\n /**\n * Whether the associated form control is required.\n * Adds visual indicator and updates ARIA attributes.\n * @default false\n */\n required?: boolean;\n\n /**\n * Whether the associated form control is disabled.\n * Updates styling to indicate disabled state.\n * @default false\n */\n disabled?: boolean;\n\n /**\n * Additional CSS classes for custom styling\n * @example \"text-red-600 font-bold\"\n */\n className?: string;\n}\n\n/**\n * Label Component\n *\n * A form label component that provides accessible labeling for form controls.\n * Establishes proper relationships between labels and their associated form elements\n * with visual indicators for required and disabled states.\n *\n * @example\n * ```tsx\n * // Basic usage\n * <Label htmlFor=\"email\">Email Address</Label>\n * <input id=\"email\" type=\"email\" />\n *\n * // Required field\n * <Label htmlFor=\"password\" required>Password</Label>\n * <input id=\"password\" type=\"password\" required />\n *\n * // Disabled field\n * <Label htmlFor=\"disabled-field\" disabled>Disabled Field</Label>\n * <input id=\"disabled-field\" type=\"text\" disabled />\n *\n * // With custom styling\n * <Label htmlFor=\"custom\" className=\"text-blue-600 font-semibold\">\n * Custom Styled Label\n * </Label>\n * ```\n *\n * @component\n * @accessibility\n * - Uses semantic HTML <label> element\n * - Properly associates with form controls via htmlFor/id relationship\n * - Supports click-to-focus behavior automatically\n * - Visual indicators for required and disabled states\n * - Screen reader compatible with proper ARIA relationships\n */\nexport const Label: FC<LabelProps> = ({\n htmlFor,\n required = false,\n disabled = false,\n className,\n children,\n ...props\n}) => (\n <label\n className={cn(\n 'select-none font-medium text-sm leading-none',\n 'peer-disabled:cursor-not-allowed peer-disabled:opacity-70',\n disabled && 'cursor-not-allowed text-muted-foreground opacity-70',\n className\n )}\n htmlFor={htmlFor}\n suppressHydrationWarning\n {...props}\n >\n {children}\n {required && (\n <span\n className=\"ml-1 text-destructive\"\n aria-label=\"required\"\n title=\"This field is required\"\n >\n *\n </span>\n )}\n </label>\n);\n"],"mappings":"0FAuEA,MAAa,GAAyB,CACpC,UACA,WAAW,GACX,WAAW,GACX,YACA,WACA,GAAG,KAEH,EAAC,QAAD,CACE,UAAW,EACT,+CACA,4DACA,GAAY,sDACZ,EACD,CACQ,UACT,yBAAA,GACA,GAAI,WATN,CAWG,EACA,GACC,EAAC,OAAD,CACE,UAAU,wBACV,aAAW,WACX,MAAM,kCACP,IAEM,CAAA,CAEH"}
@@ -1,2 +1,2 @@
1
- "use client";import{cn as e}from"../../utils/cn.mjs";import{Container as t}from"../Container/index.mjs";import{Flag as n}from"../Flags/Flag.mjs";import{useEffect as r,useState as i}from"react";import{Fragment as a,jsx as o,jsxs as s}from"react/jsx-runtime";import{Locales as c,getHTMLTextDir as l,getLocaleName as u}from"intlayer";const d=(e,t)=>{let n=[...e];for(let e=n.length-1;e>0;e--){let t=Math.floor(Math.random()*(e+1));[n[e],n[t]]=[n[t],n[e]]}return t?n.slice(0,t):n},f=({locale:e,...r})=>o(`div`,{className:`group z-10 mx-8 inline-flex shrink-0 transition-transform duration-300 hover:scale-105`,...r,children:s(t,{roundedSize:`xl`,className:`flex flex-row items-center gap-5 p-3`,children:[o(n,{locale:e,className:`max-h-5 max-w-5 rounded-sm grayscale-80 transition duration-300 group-hover:grayscale-0`,width:640,height:480,loading:`lazy`}),o(`span`,{dir:l(e),lang:e,className:`flex text-nowrap`,children:u(e)})]})}),p=({localeList:t,className:n,...r})=>o(`div`,{className:`relative flex w-full overflow-hidden`,...r,children:s(`div`,{className:e(`inline-flex shrink-0 will-change-transform`,n),children:[t.map((e,t)=>o(f,{locale:e},`${e}-first-${t}`)),t.map((e,t)=>o(f,{locale:e},`${e}-second-${t}`))]})}),m=[,,,,].fill(0).map(()=>[]),h=[,,,,].fill(0).map(()=>d(Object.values(c.ALL_LOCALES),15)),g=({className:t,...n})=>{let[a,c]=i(m),[l,u,d,f]=a;return r(()=>{c(h)},[]),o(`section`,{className:e(`mask-[linear-gradient(to_right,transparent_0,black_128px,black_calc(100%-128px),transparent_100%)] my-10 w-full overflow-hidden`,t),...n,children:s(`div`,{className:`relative flex w-full flex-col gap-5 py-3`,children:[o(p,{localeList:l,className:`horizontal-loop-1`}),o(p,{localeList:u,className:`horizontal-loop-2`}),o(p,{localeList:d,className:`horizontal-loop-1`}),o(p,{localeList:f,className:`horizontal-loop-2`})]})})},_=({children:e})=>s(a,{children:[o(`div`,{className:`absolute top-0 left-0 z-0 flex size-full items-center justify-center`,children:o(g,{className:`mt-[30%]`})}),e]});export{_ as LanguageBackground,g as LanguageSection};
1
+ "use client";import{cn as e}from"../../utils/cn.mjs";import{Container as t}from"../Container/index.mjs";import{Flag as n}from"../Flags/Flag.mjs";import{useEffect as r,useState as i}from"react";import{Fragment as a,jsx as o,jsxs as s}from"react/jsx-runtime";import{ALL_LOCALES as c,getHTMLTextDir as l,getLocaleName as u}from"intlayer";const d=(e,t)=>{let n=[...e];for(let e=n.length-1;e>0;e--){let t=Math.floor(Math.random()*(e+1));[n[e],n[t]]=[n[t],n[e]]}return t?n.slice(0,t):n},f=({locale:e,...r})=>o(`div`,{className:`group z-10 mx-8 inline-flex shrink-0 transition-transform duration-300 hover:scale-105`,...r,children:s(t,{roundedSize:`xl`,className:`flex flex-row items-center gap-5 p-3`,children:[o(n,{locale:e,className:`max-h-5 max-w-5 rounded-sm grayscale-80 transition duration-300 group-hover:grayscale-0`,width:640,height:480,loading:`lazy`}),o(`span`,{dir:l(e),lang:e,className:`flex text-nowrap`,children:u(e)})]})}),p=({localeList:t,className:n,...r})=>o(`div`,{className:`relative flex w-full overflow-hidden`,...r,children:s(`div`,{className:e(`inline-flex shrink-0 will-change-transform`,n),children:[t.map((e,t)=>o(f,{locale:e},`${e}-first-${t}`)),t.map((e,t)=>o(f,{locale:e},`${e}-second-${t}`))]})}),m=[,,,,].fill(0).map(()=>[]),h=[,,,,].fill(0).map(()=>d(Object.values(c),15)),g=({className:t,...n})=>{let[a,c]=i(m),[l,u,d,f]=a;return r(()=>{c(h)},[]),o(`section`,{className:e(`mask-[linear-gradient(to_right,transparent_0,black_128px,black_calc(100%-128px),transparent_100%)] my-10 w-full overflow-hidden`,t),...n,children:s(`div`,{className:`relative flex w-full flex-col gap-5 py-3`,children:[o(p,{localeList:l,className:`horizontal-loop-1`}),o(p,{localeList:u,className:`horizontal-loop-2`}),o(p,{localeList:d,className:`horizontal-loop-1`}),o(p,{localeList:f,className:`horizontal-loop-2`})]})})},_=({children:e})=>s(a,{children:[o(`div`,{className:`absolute top-0 left-0 z-0 flex size-full items-center justify-center`,children:o(g,{className:`mt-[30%]`})}),e]});export{_ as LanguageBackground,g as LanguageSection};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/components/LanguageBackground/index.tsx"],"sourcesContent":["'use client';\n\nimport { cn } from '@utils/cn';\nimport { getHTMLTextDir, getLocaleName, type Locale, Locales } from 'intlayer';\nimport {\n type FC,\n type HTMLAttributes,\n type PropsWithChildren,\n useEffect,\n useState,\n} from 'react';\nimport { Container } from '../Container';\nimport { Flag } from '../Flags';\n\nconst shuffleArray = (array: string[], limit?: number) => {\n const shuffled = [...array];\n\n for (let i = shuffled.length - 1; i > 0; i--) {\n const randomIndex = Math.floor(Math.random() * (i + 1));\n\n [shuffled[i], shuffled[randomIndex]] = [shuffled[randomIndex], shuffled[i]];\n }\n\n return limit ? shuffled.slice(0, limit) : shuffled;\n};\n\nconst LocalCard: FC<{ locale: string }> = ({ locale, ...props }) => (\n <div\n className=\"group z-10 mx-8 inline-flex shrink-0 transition-transform duration-300 hover:scale-105\"\n {...props}\n >\n <Container\n roundedSize=\"xl\"\n className=\"flex flex-row items-center gap-5 p-3\"\n >\n <Flag\n locale={locale as Locale}\n className=\"max-h-5 max-w-5 rounded-sm grayscale-80 transition duration-300 group-hover:grayscale-0\"\n width={640}\n height={480}\n loading=\"lazy\"\n />\n <span\n dir={getHTMLTextDir(locale as Locale)}\n lang={locale as Locale}\n className=\"flex text-nowrap\"\n >\n {getLocaleName(locale as Locale)}\n </span>\n </Container>\n </div>\n);\n\nconst LocalCardList: FC<{ localeList: string[]; className?: string }> = ({\n localeList,\n className,\n ...props\n}) => (\n <div className=\"relative flex w-full overflow-hidden\" {...props}>\n <div\n className={cn('inline-flex shrink-0 will-change-transform', className)}\n >\n {/* First set of cards */}\n {localeList.map((locale, index) => (\n <LocalCard key={`${locale}-first-${index}`} locale={locale} />\n ))}\n {/* Duplicate set for seamless loop */}\n {localeList.map((locale, index) => (\n <LocalCard key={`${locale}-second-${index}`} locale={locale} />\n ))}\n </div>\n </div>\n);\n\nconst NUM_OF_LOCALES = 15;\n\nconst emptyArrayOfLocale: string[][] = new Array(4).fill(0).map(() => []);\nconst arrayOfLocale: string[][] = new Array(4)\n .fill(0)\n .map(() => shuffleArray(Object.values(Locales.ALL_LOCALES), NUM_OF_LOCALES));\n\nexport const LanguageSection: FC<HTMLAttributes<HTMLElement>> = ({\n className,\n ...props\n}) => {\n const [localeList, setLocaleList] = useState(emptyArrayOfLocale);\n const [firstPart, secondPart, thirdPart, fourthPart] = localeList;\n\n useEffect(() => {\n setLocaleList(arrayOfLocale);\n }, []);\n\n return (\n <section\n className={cn(\n 'mask-[linear-gradient(to_right,transparent_0,black_128px,black_calc(100%-128px),transparent_100%)] my-10 w-full overflow-hidden',\n className\n )}\n {...props}\n >\n <div className=\"relative flex w-full flex-col gap-5 py-3\">\n <LocalCardList localeList={firstPart} className=\"horizontal-loop-1\" />\n <LocalCardList localeList={secondPart} className=\"horizontal-loop-2\" />\n <LocalCardList localeList={thirdPart} className=\"horizontal-loop-1\" />\n <LocalCardList localeList={fourthPart} className=\"horizontal-loop-2\" />\n </div>\n </section>\n );\n};\n\nexport const LanguageBackground: FC<PropsWithChildren> = ({ children }) => (\n <>\n <div className=\"absolute top-0 left-0 z-0 flex size-full items-center justify-center\">\n <LanguageSection className=\"mt-[30%]\" />\n </div>\n {children}\n </>\n);\n"],"mappings":"2UAcA,MAAM,GAAgB,EAAiB,IAAmB,CACxD,IAAM,EAAW,CAAC,GAAG,EAAM,CAE3B,IAAK,IAAI,EAAI,EAAS,OAAS,EAAG,EAAI,EAAG,IAAK,CAC5C,IAAM,EAAc,KAAK,MAAM,KAAK,QAAQ,EAAI,EAAI,GAAG,CAEvD,CAAC,EAAS,GAAI,EAAS,IAAgB,CAAC,EAAS,GAAc,EAAS,GAAG,CAG7E,OAAO,EAAQ,EAAS,MAAM,EAAG,EAAM,CAAG,GAGtC,GAAqC,CAAE,SAAQ,GAAG,KACtD,EAAC,MAAD,CACE,UAAU,yFACV,GAAI,WAEJ,EAAC,EAA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E,CAAA,EAID,GAA6C,CAAE,cAC1D,EAAA,EAAA,CAAA,SAAA,CACE,EAAC,MAAD,CAAK,UAAU,gFACb,EAAC,EAAD,CAAiB,UAAU,WAAa,CAAA,CACpC,CAAA,CACL,EACA,CAAA,CAAA"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/components/LanguageBackground/index.tsx"],"sourcesContent":["'use client';\n\nimport { cn } from '@utils/cn';\nimport {\n ALL_LOCALES,\n getHTMLTextDir,\n getLocaleName,\n type Locale,\n} from 'intlayer';\nimport {\n type FC,\n type HTMLAttributes,\n type PropsWithChildren,\n useEffect,\n useState,\n} from 'react';\nimport { Container } from '../Container';\nimport { Flag } from '../Flags';\n\nconst shuffleArray = (array: string[], limit?: number) => {\n const shuffled = [...array];\n\n for (let i = shuffled.length - 1; i > 0; i--) {\n const randomIndex = Math.floor(Math.random() * (i + 1));\n\n [shuffled[i], shuffled[randomIndex]] = [shuffled[randomIndex], shuffled[i]];\n }\n\n return limit ? shuffled.slice(0, limit) : shuffled;\n};\n\nconst LocalCard: FC<{ locale: string }> = ({ locale, ...props }) => (\n <div\n className=\"group z-10 mx-8 inline-flex shrink-0 transition-transform duration-300 hover:scale-105\"\n {...props}\n >\n <Container\n roundedSize=\"xl\"\n className=\"flex flex-row items-center gap-5 p-3\"\n >\n <Flag\n locale={locale as Locale}\n className=\"max-h-5 max-w-5 rounded-sm grayscale-80 transition duration-300 group-hover:grayscale-0\"\n width={640}\n height={480}\n loading=\"lazy\"\n />\n <span\n dir={getHTMLTextDir(locale as Locale)}\n lang={locale as Locale}\n className=\"flex text-nowrap\"\n >\n {getLocaleName(locale as Locale)}\n </span>\n </Container>\n </div>\n);\n\nconst LocalCardList: FC<{ localeList: string[]; className?: string }> = ({\n localeList,\n className,\n ...props\n}) => (\n <div className=\"relative flex w-full overflow-hidden\" {...props}>\n <div\n className={cn('inline-flex shrink-0 will-change-transform', className)}\n >\n {/* First set of cards */}\n {localeList.map((locale, index) => (\n <LocalCard key={`${locale}-first-${index}`} locale={locale} />\n ))}\n {/* Duplicate set for seamless loop */}\n {localeList.map((locale, index) => (\n <LocalCard key={`${locale}-second-${index}`} locale={locale} />\n ))}\n </div>\n </div>\n);\n\nconst NUM_OF_LOCALES = 15;\n\nconst emptyArrayOfLocale: string[][] = new Array(4).fill(0).map(() => []);\nconst arrayOfLocale: string[][] = new Array(4)\n .fill(0)\n .map(() => shuffleArray(Object.values(ALL_LOCALES), NUM_OF_LOCALES));\n\nexport const LanguageSection: FC<HTMLAttributes<HTMLElement>> = ({\n className,\n ...props\n}) => {\n const [localeList, setLocaleList] = useState(emptyArrayOfLocale);\n const [firstPart, secondPart, thirdPart, fourthPart] = localeList;\n\n useEffect(() => {\n setLocaleList(arrayOfLocale);\n }, []);\n\n return (\n <section\n className={cn(\n 'mask-[linear-gradient(to_right,transparent_0,black_128px,black_calc(100%-128px),transparent_100%)] my-10 w-full overflow-hidden',\n className\n )}\n {...props}\n >\n <div className=\"relative flex w-full flex-col gap-5 py-3\">\n <LocalCardList localeList={firstPart} className=\"horizontal-loop-1\" />\n <LocalCardList localeList={secondPart} className=\"horizontal-loop-2\" />\n <LocalCardList localeList={thirdPart} className=\"horizontal-loop-1\" />\n <LocalCardList localeList={fourthPart} className=\"horizontal-loop-2\" />\n </div>\n </section>\n );\n};\n\nexport const LanguageBackground: FC<PropsWithChildren> = ({ children }) => (\n <>\n <div className=\"absolute top-0 left-0 z-0 flex size-full items-center justify-center\">\n <LanguageSection className=\"mt-[30%]\" />\n </div>\n {children}\n </>\n);\n"],"mappings":"+UAmBA,MAAM,GAAgB,EAAiB,IAAmB,CACxD,IAAM,EAAW,CAAC,GAAG,EAAM,CAE3B,IAAK,IAAI,EAAI,EAAS,OAAS,EAAG,EAAI,EAAG,IAAK,CAC5C,IAAM,EAAc,KAAK,MAAM,KAAK,QAAQ,EAAI,EAAI,GAAG,CAEvD,CAAC,EAAS,GAAI,EAAS,IAAgB,CAAC,EAAS,GAAc,EAAS,GAAG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oBAAsB,CAAA,CACvE,EAAC,EAAD,CAAe,WAAY,EAAW,UAAU,oBAAsB,CAAA,CACtE,EAAC,EAAD,CAAe,WAAY,EAAY,UAAU,oBAAsB,CAAA,CACnE,GACE,CAAA,EAID,GAA6C,CAAE,cAC1D,EAAA,EAAA,CAAA,SAAA,CACE,EAAC,MAAD,CAAK,UAAU,gFACb,EAAC,EAAD,CAAiB,UAAU,WAAa,CAAA,CACpC,CAAA,CACL,EACA,CAAA,CAAA"}
@@ -1,2 +1,2 @@
1
- import{cn as e}from"../../utils/cn.mjs";import{ExternalLink as t,MoveRight as n}from"lucide-react";import{isValidElement as r}from"react";import{cva as i}from"class-variance-authority";import{jsx as a,jsxs as o}from"react/jsx-runtime";import{getLocalizedUrl as s}from"@intlayer/core/localization";let c=function(e){return e.DEFAULT=`default`,e.INVISIBLE_LINK=`invisible-link`,e.BUTTON=`button`,e.BUTTON_OUTLINED=`button-outlined`,e.HOVERABLE=`hoverable`,e}({}),l=function(e){return e.PRIMARY=`primary`,e.SECONDARY=`secondary`,e.DESTRUCTIVE=`destructive`,e.NEUTRAL=`neutral`,e.LIGHT=`light`,e.DARK=`dark`,e.TEXT=`text`,e.TEXT_INVERSE=`text-inverse`,e.ERROR=`error`,e.SUCCESS=`success`,e.CUSTOM=`custom`,e}({}),u=function(e){return e.NONE=`none`,e.SM=`sm`,e.MD=`md`,e.LG=`lg`,e.XL=`xl`,e.TWO_XL=`2xl`,e.THREE_XL=`3xl`,e.FULL=`full`,e}({}),d=function(e){return e.SM=`sm`,e.MD=`md`,e.LG=`lg`,e.XL=`xl`,e.CUSTOM=`custom`,e}({}),f=function(e){return e.DEFAULT=`default`,e.TRUE=`true`,e.FALSE=`false`,e}({});const p=i(`gap-3 transition-all duration-300 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50`,{variants:{variant:{[`${c.DEFAULT}`]:`h-auto justify-start border-inherit bg-current/0 px-1 font-medium decoration-[1.5] underline-offset-5 hover:bg-current/0 hover:text-current/80 hover:underline hover:underline-offset-6`,[`${c.INVISIBLE_LINK}`]:`h-auto justify-start border-inherit bg-current/0 px-1 underline-offset-5 hover:bg-current/0`,[`${c.BUTTON}`]:`relative flex cursor-pointer flex-row items-center justify-center gap-2 rounded-full bg-current text-center font-medium text-text ring-0 *:text-text-opposite hover:bg-current/90 hover:ring-5 aria-selected:ring-5`,[`${c.BUTTON_OUTLINED}`]:`relative flex cursor-pointer flex-row items-center justify-center gap-2 rounded-full border-[1.3px] border-current text-center font-medium text-text ring-0 *:text-text hover:bg-current/20 hover:ring-5 aria-selected:ring-5`,[`${c.HOVERABLE}`]:`block rounded-lg border-none bg-current/0 hover:bg-current/10 aria-[current]:bg-current/5`},roundedSize:{[`${u.NONE}`]:`rounded-none`,[`${u.SM}`]:`rounded-lg [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-xl`,[`${u.MD}`]:`rounded-xl [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-2xl`,[`${u.LG}`]:`rounded-2xl [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-3xl`,[`${u.XL}`]:`rounded-3xl [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-4xl`,[`${u.TWO_XL}`]:`rounded-4xl [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[2.5rem]`,[`${u.THREE_XL}`]:`rounded-[2.5rem] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[3rem]`,[`${u.FULL}`]:`rounded-full`},color:{[`${l.PRIMARY}`]:`text-primary`,[`${l.SECONDARY}`]:`text-secondary`,[`${l.DESTRUCTIVE}`]:`text-destructive`,[`${l.NEUTRAL}`]:`text-neutral`,[`${l.LIGHT}`]:`text-white`,[`${l.DARK}`]:`text-neutral-800`,[`${l.TEXT}`]:`text-text`,[`${l.TEXT_INVERSE}`]:`text-text-opposite`,[`${l.ERROR}`]:`text-error`,[`${l.SUCCESS}`]:`text-success`,[`${l.CUSTOM}`]:``},size:{[`${d.SM}`]:`text-sm`,[`${d.MD}`]:`text-base`,[`${d.LG}`]:`text-lg`,[`${d.XL}`]:`text-xl`,[`${d.CUSTOM}`]:``},underlined:{[f.DEFAULT]:``,[f.TRUE]:`underline`,[f.FALSE]:`no-underline`}},compoundVariants:[{variant:c.BUTTON,color:l.TEXT_INVERSE,class:`*:text-text`},{variant:c.BUTTON_OUTLINED,color:l.TEXT_INVERSE,class:`text-text-opposite *:text-text-opposite`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],size:d.SM,class:`min-h-7 px-3 max-md:py-1`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],size:d.MD,class:`min-h-8 px-6 max-md:py-2`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],size:d.LG,class:`min-h-10 px-8 max-md:py-3`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],size:d.XL,class:`min-h-11 px-10 max-md:py-4`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],color:l.PRIMARY,class:`ring-primary/20`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],color:l.SECONDARY,class:`ring-secondary/20`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],color:l.DESTRUCTIVE,class:`ring-destructive/20`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],color:l.NEUTRAL,class:`ring-neutral/20`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],color:l.LIGHT,class:`ring-white/20`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],color:l.DARK,class:`ring-neutral-800/20`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],color:l.TEXT,class:`ring-text/20`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],color:l.TEXT_INVERSE,class:`ring-text-opposite/20`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],color:l.ERROR,class:`ring-error/20`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],color:l.SUCCESS,class:`ring-success/20`}],defaultVariants:{variant:c.DEFAULT,roundedSize:u.MD,underlined:f.DEFAULT,size:d.MD}}),m=({href:e,isExternalLink:t})=>{let n=typeof e==`string`&&e.trim()!==``;return t===!0||t===void 0&&n&&/^https?:\/\//.test(e)},h=e=>typeof e==`string`||typeof e==`number`?!0:Array.isArray(e)?e.every(h):r(e)?h(e.props.children):!1,g=r=>{let{variant:i=c.DEFAULT,color:u=l.CUSTOM,roundedSize:d,children:f,label:g,className:_,isActive:v,underlined:y,locale:b,size:x,isExternalLink:S,isPageSection:C,href:w,...T}=r,E=S??m(r),D=C??w?.startsWith(`#`)??!1,O=h(f),k=i===c.BUTTON||i===c.BUTTON_OUTLINED,A=E?`noopener noreferrer nofollow`:void 0,j=E?`_blank`:`_self`;return o(`a`,{href:b&&w&&!E&&!D?s(w,b):w,"aria-label":g,rel:A,target:j,"aria-current":v?`page`:void 0,className:e(p({variant:i,color:u,roundedSize:d,underlined:y,size:x,className:_})),...T,children:[k&&O?a(`span`,{children:f}):f,E&&O&&a(t,{className:`ml-2 inline-block size-4`}),D&&a(n,{className:`ml-2 inline-block size-4`})]})};export{g as Link,l as LinkColor,u as LinkRoundedSize,d as LinkSize,f as LinkUnderlined,c as LinkVariant,m as checkIsExternalLink,h as isTextChildren,p as linkVariants};
1
+ import{cn as e}from"../../utils/cn.mjs";import{isValidElement as t}from"react";import{cva as n}from"class-variance-authority";import{ExternalLink as r,MoveRight as i}from"lucide-react";import{jsx as a,jsxs as o}from"react/jsx-runtime";import{getLocalizedUrl as s}from"@intlayer/core/localization";let c=function(e){return e.DEFAULT=`default`,e.INVISIBLE_LINK=`invisible-link`,e.BUTTON=`button`,e.BUTTON_OUTLINED=`button-outlined`,e.HOVERABLE=`hoverable`,e}({}),l=function(e){return e.PRIMARY=`primary`,e.SECONDARY=`secondary`,e.DESTRUCTIVE=`destructive`,e.NEUTRAL=`neutral`,e.LIGHT=`light`,e.DARK=`dark`,e.TEXT=`text`,e.TEXT_INVERSE=`text-inverse`,e.ERROR=`error`,e.SUCCESS=`success`,e.CUSTOM=`custom`,e}({}),u=function(e){return e.NONE=`none`,e.SM=`sm`,e.MD=`md`,e.LG=`lg`,e.XL=`xl`,e.TWO_XL=`2xl`,e.THREE_XL=`3xl`,e.FULL=`full`,e}({}),d=function(e){return e.SM=`sm`,e.MD=`md`,e.LG=`lg`,e.XL=`xl`,e.CUSTOM=`custom`,e}({}),f=function(e){return e.DEFAULT=`default`,e.TRUE=`true`,e.FALSE=`false`,e}({});const p=n(`gap-3 transition-all duration-300 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50`,{variants:{variant:{[`${c.DEFAULT}`]:`h-auto justify-start border-inherit bg-current/0 px-1 font-medium decoration-[1.5] underline-offset-5 hover:bg-current/0 hover:text-current/80 hover:underline hover:underline-offset-6`,[`${c.INVISIBLE_LINK}`]:`h-auto justify-start border-inherit bg-current/0 px-1 underline-offset-5 hover:bg-current/0`,[`${c.BUTTON}`]:`relative flex cursor-pointer flex-row items-center justify-center gap-2 rounded-full bg-current text-center font-medium text-text ring-0 *:text-text-opposite hover:bg-current/90 hover:ring-5 aria-selected:ring-5`,[`${c.BUTTON_OUTLINED}`]:`relative flex cursor-pointer flex-row items-center justify-center gap-2 rounded-full border-[1.3px] border-current text-center font-medium text-text ring-0 *:text-text hover:bg-current/20 hover:ring-5 aria-selected:ring-5`,[`${c.HOVERABLE}`]:`block rounded-lg border-none bg-current/0 hover:bg-current/10 aria-[current]:bg-current/5`},roundedSize:{[`${u.NONE}`]:`rounded-none`,[`${u.SM}`]:`rounded-lg [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-xl`,[`${u.MD}`]:`rounded-xl [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-2xl`,[`${u.LG}`]:`rounded-2xl [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-3xl`,[`${u.XL}`]:`rounded-3xl [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-4xl`,[`${u.TWO_XL}`]:`rounded-4xl [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[2.5rem]`,[`${u.THREE_XL}`]:`rounded-[2.5rem] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[3rem]`,[`${u.FULL}`]:`rounded-full`},color:{[`${l.PRIMARY}`]:`text-primary`,[`${l.SECONDARY}`]:`text-secondary`,[`${l.DESTRUCTIVE}`]:`text-destructive`,[`${l.NEUTRAL}`]:`text-neutral`,[`${l.LIGHT}`]:`text-white`,[`${l.DARK}`]:`text-neutral-800`,[`${l.TEXT}`]:`text-text`,[`${l.TEXT_INVERSE}`]:`text-text-opposite`,[`${l.ERROR}`]:`text-error`,[`${l.SUCCESS}`]:`text-success`,[`${l.CUSTOM}`]:``},size:{[`${d.SM}`]:`text-sm`,[`${d.MD}`]:`text-base`,[`${d.LG}`]:`text-lg`,[`${d.XL}`]:`text-xl`,[`${d.CUSTOM}`]:``},underlined:{[f.DEFAULT]:``,[f.TRUE]:`underline`,[f.FALSE]:`no-underline`}},compoundVariants:[{variant:c.BUTTON,color:l.TEXT_INVERSE,class:`*:text-text`},{variant:c.BUTTON_OUTLINED,color:l.TEXT_INVERSE,class:`text-text-opposite *:text-text-opposite`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],size:d.SM,class:`min-h-7 px-3 max-md:py-1`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],size:d.MD,class:`min-h-8 px-6 max-md:py-2`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],size:d.LG,class:`min-h-10 px-8 max-md:py-3`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],size:d.XL,class:`min-h-11 px-10 max-md:py-4`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],color:l.PRIMARY,class:`ring-primary/20`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],color:l.SECONDARY,class:`ring-secondary/20`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],color:l.DESTRUCTIVE,class:`ring-destructive/20`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],color:l.NEUTRAL,class:`ring-neutral/20`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],color:l.LIGHT,class:`ring-white/20`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],color:l.DARK,class:`ring-neutral-800/20`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],color:l.TEXT,class:`ring-text/20`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],color:l.TEXT_INVERSE,class:`ring-text-opposite/20`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],color:l.ERROR,class:`ring-error/20`},{variant:[c.BUTTON,c.BUTTON_OUTLINED],color:l.SUCCESS,class:`ring-success/20`}],defaultVariants:{variant:c.DEFAULT,roundedSize:u.MD,underlined:f.DEFAULT,size:d.MD}}),m=({href:e,isExternalLink:t})=>{let n=typeof e==`string`&&e.trim()!==``;return t===!0||t===void 0&&n&&/^https?:\/\//.test(e)},h=e=>typeof e==`string`||typeof e==`number`?!0:Array.isArray(e)?e.every(h):t(e)?h(e.props.children):!1,g=t=>{let{variant:n=c.DEFAULT,color:u=l.CUSTOM,roundedSize:d,children:f,label:g,className:_,isActive:v,underlined:y,locale:b,size:x,isExternalLink:S,isPageSection:C,href:w,...T}=t,E=S??m(t),D=C??w?.startsWith(`#`)??!1,O=h(f),k=n===c.BUTTON||n===c.BUTTON_OUTLINED,A=E?`noopener noreferrer nofollow`:void 0,j=E?`_blank`:`_self`;return o(`a`,{href:b&&w&&!E&&!D?s(w,b):w,"aria-label":g,rel:A,target:j,"aria-current":v?`page`:void 0,suppressHydrationWarning:!0,className:e(p({variant:n,color:u,roundedSize:d,underlined:y,size:x,className:_})),...T,children:[k&&O?a(`span`,{children:f}):f,E&&O&&a(r,{className:`ml-2 inline-block size-4`}),D&&a(i,{className:`ml-2 inline-block size-4`})]})};export{g as Link,l as LinkColor,u as LinkRoundedSize,d as LinkSize,f as LinkUnderlined,c as LinkVariant,m as checkIsExternalLink,h as isTextChildren,p as linkVariants};
2
2
  //# sourceMappingURL=Link.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Link.mjs","names":[],"sources":["../../../../src/components/Link/Link.tsx"],"sourcesContent":["import { getLocalizedUrl } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types';\nimport { cn } from '@utils/cn';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { ExternalLink, MoveRight } from 'lucide-react';\nimport {\n type AnchorHTMLAttributes,\n type DetailedHTMLProps,\n type FC,\n isValidElement,\n type ReactNode,\n} from 'react';\n\n/**\n * Visual style variants for Link component\n */\nexport enum LinkVariant {\n DEFAULT = 'default',\n INVISIBLE_LINK = 'invisible-link',\n BUTTON = 'button',\n BUTTON_OUTLINED = 'button-outlined',\n HOVERABLE = 'hoverable',\n}\n\n/**\n * Color theme variants for Link component\n */\nexport enum LinkColor {\n PRIMARY = 'primary',\n SECONDARY = 'secondary',\n DESTRUCTIVE = 'destructive',\n NEUTRAL = 'neutral',\n LIGHT = 'light',\n DARK = 'dark',\n TEXT = 'text',\n TEXT_INVERSE = 'text-inverse',\n ERROR = 'error',\n SUCCESS = 'success',\n CUSTOM = 'custom',\n}\n\nexport enum LinkRoundedSize {\n NONE = 'none',\n SM = 'sm',\n MD = 'md',\n LG = 'lg',\n XL = 'xl',\n TWO_XL = '2xl',\n THREE_XL = '3xl',\n FULL = 'full',\n}\n\nexport enum LinkSize {\n SM = 'sm',\n MD = 'md',\n LG = 'lg',\n XL = 'xl',\n CUSTOM = 'custom',\n}\n\nexport enum LinkUnderlined {\n DEFAULT = 'default',\n TRUE = 'true',\n FALSE = 'false',\n}\n\nexport const linkVariants = cva(\n 'gap-3 transition-all duration-300 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50',\n {\n variants: {\n variant: {\n [`${LinkVariant.DEFAULT}`]:\n 'h-auto justify-start border-inherit bg-current/0 px-1 font-medium decoration-[1.5] underline-offset-5 hover:bg-current/0 hover:text-current/80 hover:underline hover:underline-offset-6',\n [`${LinkVariant.INVISIBLE_LINK}`]:\n 'h-auto justify-start border-inherit bg-current/0 px-1 underline-offset-5 hover:bg-current/0',\n\n [`${LinkVariant.BUTTON}`]:\n 'relative flex cursor-pointer flex-row items-center justify-center gap-2 rounded-full bg-current text-center font-medium text-text ring-0 *:text-text-opposite hover:bg-current/90 hover:ring-5 aria-selected:ring-5',\n\n [`${LinkVariant.BUTTON_OUTLINED}`]:\n 'relative flex cursor-pointer flex-row items-center justify-center gap-2 rounded-full border-[1.3px] border-current text-center font-medium text-text ring-0 *:text-text hover:bg-current/20 hover:ring-5 aria-selected:ring-5',\n\n [`${LinkVariant.HOVERABLE}`]:\n 'block rounded-lg border-none bg-current/0 hover:bg-current/10 aria-[current]:bg-current/5',\n },\n roundedSize: {\n [`${LinkRoundedSize.NONE}`]: 'rounded-none',\n [`${LinkRoundedSize.SM}`]:\n 'rounded-lg [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-xl',\n [`${LinkRoundedSize.MD}`]:\n 'rounded-xl [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-2xl',\n [`${LinkRoundedSize.LG}`]:\n 'rounded-2xl [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-3xl',\n [`${LinkRoundedSize.XL}`]:\n 'rounded-3xl [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-4xl',\n [`${LinkRoundedSize.TWO_XL}`]:\n 'rounded-4xl [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[2.5rem]',\n [`${LinkRoundedSize.THREE_XL}`]:\n 'rounded-[2.5rem] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[3rem]',\n [`${LinkRoundedSize.FULL}`]: 'rounded-full',\n },\n color: {\n [`${LinkColor.PRIMARY}`]: 'text-primary',\n [`${LinkColor.SECONDARY}`]: 'text-secondary',\n [`${LinkColor.DESTRUCTIVE}`]: 'text-destructive',\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 size: {\n [`${LinkSize.SM}`]: 'text-sm',\n [`${LinkSize.MD}`]: 'text-base',\n [`${LinkSize.LG}`]: 'text-lg',\n [`${LinkSize.XL}`]: 'text-xl',\n [`${LinkSize.CUSTOM}`]: '',\n },\n underlined: {\n [LinkUnderlined.DEFAULT]: '',\n [LinkUnderlined.TRUE]: 'underline',\n [LinkUnderlined.FALSE]: 'no-underline',\n },\n },\n // Compound variants handle height and padding\n compoundVariants: [\n // ---------------------------------------------------------\n // FIX START: Correctly Handle Contrast for TEXT_INVERSE\n // ---------------------------------------------------------\n {\n // Filled Button + Inverse Color (e.g., White Button):\n // We DO NOT override parent text color (it must remain 'text-opposite' so bg-current is white).\n // We ONLY override children to be 'text-text' (Dark) so they show up on white.\n variant: LinkVariant.BUTTON,\n color: LinkColor.TEXT_INVERSE,\n class: '*:text-text',\n },\n {\n // Outlined Button + Inverse Color (e.g., White Border):\n // Parent is 'text-opposite' (Border is white).\n // Children must also be 'text-opposite' (White text) to show on dark background.\n variant: LinkVariant.BUTTON_OUTLINED,\n color: LinkColor.TEXT_INVERSE,\n class: 'text-text-opposite *:text-text-opposite',\n },\n\n // Min height and padding for button variants\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n size: LinkSize.SM,\n class: 'min-h-7 px-3 max-md:py-1',\n },\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n size: LinkSize.MD,\n class: 'min-h-8 px-6 max-md:py-2',\n },\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n size: LinkSize.LG,\n class: 'min-h-10 px-8 max-md:py-3',\n },\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n size: LinkSize.XL,\n class: 'min-h-11 px-10 max-md:py-4',\n },\n // Ring color variants\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n color: LinkColor.PRIMARY,\n class: 'ring-primary/20',\n },\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n color: LinkColor.SECONDARY,\n class: 'ring-secondary/20',\n },\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n color: LinkColor.DESTRUCTIVE,\n class: 'ring-destructive/20',\n },\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n color: LinkColor.NEUTRAL,\n class: 'ring-neutral/20',\n },\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n color: LinkColor.LIGHT,\n class: 'ring-white/20',\n },\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n color: LinkColor.DARK,\n class: 'ring-neutral-800/20',\n },\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n color: LinkColor.TEXT,\n class: 'ring-text/20',\n },\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n color: LinkColor.TEXT_INVERSE,\n class: 'ring-text-opposite/20',\n },\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n color: LinkColor.ERROR,\n class: 'ring-error/20',\n },\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n color: LinkColor.SUCCESS,\n class: 'ring-success/20',\n },\n ],\n\n defaultVariants: {\n variant: LinkVariant.DEFAULT,\n roundedSize: LinkRoundedSize.MD,\n underlined: LinkUnderlined.DEFAULT,\n size: LinkSize.MD,\n },\n }\n);\n\nexport type LinkProps = DetailedHTMLProps<\n AnchorHTMLAttributes<HTMLAnchorElement>,\n HTMLAnchorElement\n> &\n VariantProps<typeof linkVariants> & {\n label: string;\n isExternalLink?: boolean;\n isPageSection?: boolean;\n isActive?: boolean;\n locale?: LocalesValues;\n };\n\nexport const checkIsExternalLink = ({\n href,\n isExternalLink: isExternalLinkProp,\n}: LinkProps): boolean => {\n const isValidHref = typeof href === 'string' && href.trim() !== '';\n const isExternalLink =\n isExternalLinkProp === true ||\n (typeof isExternalLinkProp === 'undefined' &&\n isValidHref &&\n /^https?:\\/\\//.test(href));\n\n return isExternalLink;\n};\n\nexport const isTextChildren = (children: ReactNode): boolean => {\n if (typeof children === 'string' || typeof children === 'number') {\n return true;\n }\n if (Array.isArray(children)) {\n return children.every(isTextChildren);\n }\n if (isValidElement(children)) {\n return isTextChildren(\n (children.props as { children?: ReactNode }).children\n );\n }\n return false;\n};\n\nexport const Link: FC<LinkProps> = (props) => {\n const {\n variant = LinkVariant.DEFAULT,\n color = LinkColor.CUSTOM,\n roundedSize,\n children,\n label,\n className,\n isActive,\n underlined,\n locale,\n size,\n isExternalLink: isExternalLinkProp,\n isPageSection: isPageSectionProp,\n href: hrefProp,\n ...otherProps\n } = props;\n\n const isExternalLink = isExternalLinkProp ?? checkIsExternalLink(props);\n const isPageSection = isPageSectionProp ?? hrefProp?.startsWith('#') ?? false;\n\n const isChildrenString = isTextChildren(children);\n const isButton =\n variant === LinkVariant.BUTTON || variant === LinkVariant.BUTTON_OUTLINED;\n\n const rel = isExternalLink ? 'noopener noreferrer nofollow' : undefined;\n\n const target = isExternalLink ? '_blank' : '_self';\n\n const href =\n locale && hrefProp && !isExternalLink && !isPageSection\n ? getLocalizedUrl(hrefProp, locale)\n : hrefProp;\n\n return (\n <a\n href={href}\n aria-label={label}\n rel={rel}\n target={target}\n aria-current={isActive ? 'page' : undefined}\n className={cn(\n linkVariants({\n variant,\n color,\n roundedSize,\n underlined,\n size,\n className,\n })\n )}\n {...otherProps}\n >\n {isButton && isChildrenString ? <span>{children}</span> : children}\n\n {isExternalLink && isChildrenString && (\n <ExternalLink className=\"ml-2 inline-block size-4\" />\n )}\n {isPageSection && <MoveRight className=\"ml-2 inline-block size-4\" />}\n </a>\n );\n};\n"],"mappings":"ySAgBA,IAAY,EAAL,SAAA,EAAA,OACL,GAAA,QAAA,UACA,EAAA,eA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D,CACE,KANF,GAAU,GAAY,CAAC,GAAkB,CAAC,EACtC,EAAgB,EAAU,EAAO,CACjC,EAKF,aAAY,EACP,MACG,SACR,eAAc,EAAW,OAAS,IAAA,GAClC,UAAW,EACT,EAAa,CACX,UACA,QACA,cACA,aACA,OACA,YACD,CAAC,CACH,CACD,GAAI,WAhBN,CAkBG,GAAY,EAAmB,EAAC,OAAD,CAAO,WAAgB,CAAA,CAAG,EAEzD,GAAkB,GACjB,EAAC,EAAD,CAAc,UAAU,2BAA6B,CAAA,CAEtD,GAAiB,EAAC,EAAD,CAAW,UAAU,2BAA6B,CAAA,CAClE"}
1
+ {"version":3,"file":"Link.mjs","names":[],"sources":["../../../../src/components/Link/Link.tsx"],"sourcesContent":["import { getLocalizedUrl } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { cn } from '@utils/cn';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { ExternalLink, MoveRight } from 'lucide-react';\nimport {\n type AnchorHTMLAttributes,\n type DetailedHTMLProps,\n type FC,\n isValidElement,\n type ReactNode,\n} from 'react';\n\n/**\n * Visual style variants for Link component\n */\nexport enum LinkVariant {\n DEFAULT = 'default',\n INVISIBLE_LINK = 'invisible-link',\n BUTTON = 'button',\n BUTTON_OUTLINED = 'button-outlined',\n HOVERABLE = 'hoverable',\n}\n\n/**\n * Color theme variants for Link component\n */\nexport enum LinkColor {\n PRIMARY = 'primary',\n SECONDARY = 'secondary',\n DESTRUCTIVE = 'destructive',\n NEUTRAL = 'neutral',\n LIGHT = 'light',\n DARK = 'dark',\n TEXT = 'text',\n TEXT_INVERSE = 'text-inverse',\n ERROR = 'error',\n SUCCESS = 'success',\n CUSTOM = 'custom',\n}\n\nexport enum LinkRoundedSize {\n NONE = 'none',\n SM = 'sm',\n MD = 'md',\n LG = 'lg',\n XL = 'xl',\n TWO_XL = '2xl',\n THREE_XL = '3xl',\n FULL = 'full',\n}\n\nexport enum LinkSize {\n SM = 'sm',\n MD = 'md',\n LG = 'lg',\n XL = 'xl',\n CUSTOM = 'custom',\n}\n\nexport enum LinkUnderlined {\n DEFAULT = 'default',\n TRUE = 'true',\n FALSE = 'false',\n}\n\nexport const linkVariants = cva(\n 'gap-3 transition-all duration-300 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50',\n {\n variants: {\n variant: {\n [`${LinkVariant.DEFAULT}`]:\n 'h-auto justify-start border-inherit bg-current/0 px-1 font-medium decoration-[1.5] underline-offset-5 hover:bg-current/0 hover:text-current/80 hover:underline hover:underline-offset-6',\n [`${LinkVariant.INVISIBLE_LINK}`]:\n 'h-auto justify-start border-inherit bg-current/0 px-1 underline-offset-5 hover:bg-current/0',\n\n [`${LinkVariant.BUTTON}`]:\n 'relative flex cursor-pointer flex-row items-center justify-center gap-2 rounded-full bg-current text-center font-medium text-text ring-0 *:text-text-opposite hover:bg-current/90 hover:ring-5 aria-selected:ring-5',\n\n [`${LinkVariant.BUTTON_OUTLINED}`]:\n 'relative flex cursor-pointer flex-row items-center justify-center gap-2 rounded-full border-[1.3px] border-current text-center font-medium text-text ring-0 *:text-text hover:bg-current/20 hover:ring-5 aria-selected:ring-5',\n\n [`${LinkVariant.HOVERABLE}`]:\n 'block rounded-lg border-none bg-current/0 hover:bg-current/10 aria-[current]:bg-current/5',\n },\n roundedSize: {\n [`${LinkRoundedSize.NONE}`]: 'rounded-none',\n [`${LinkRoundedSize.SM}`]:\n 'rounded-lg [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-xl',\n [`${LinkRoundedSize.MD}`]:\n 'rounded-xl [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-2xl',\n [`${LinkRoundedSize.LG}`]:\n 'rounded-2xl [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-3xl',\n [`${LinkRoundedSize.XL}`]:\n 'rounded-3xl [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-4xl',\n [`${LinkRoundedSize.TWO_XL}`]:\n 'rounded-4xl [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[2.5rem]',\n [`${LinkRoundedSize.THREE_XL}`]:\n 'rounded-[2.5rem] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[3rem]',\n [`${LinkRoundedSize.FULL}`]: 'rounded-full',\n },\n color: {\n [`${LinkColor.PRIMARY}`]: 'text-primary',\n [`${LinkColor.SECONDARY}`]: 'text-secondary',\n [`${LinkColor.DESTRUCTIVE}`]: 'text-destructive',\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 size: {\n [`${LinkSize.SM}`]: 'text-sm',\n [`${LinkSize.MD}`]: 'text-base',\n [`${LinkSize.LG}`]: 'text-lg',\n [`${LinkSize.XL}`]: 'text-xl',\n [`${LinkSize.CUSTOM}`]: '',\n },\n underlined: {\n [LinkUnderlined.DEFAULT]: '',\n [LinkUnderlined.TRUE]: 'underline',\n [LinkUnderlined.FALSE]: 'no-underline',\n },\n },\n // Compound variants handle height and padding\n compoundVariants: [\n // ---------------------------------------------------------\n // FIX START: Correctly Handle Contrast for TEXT_INVERSE\n // ---------------------------------------------------------\n {\n // Filled Button + Inverse Color (e.g., White Button):\n // We DO NOT override parent text color (it must remain 'text-opposite' so bg-current is white).\n // We ONLY override children to be 'text-text' (Dark) so they show up on white.\n variant: LinkVariant.BUTTON,\n color: LinkColor.TEXT_INVERSE,\n class: '*:text-text',\n },\n {\n // Outlined Button + Inverse Color (e.g., White Border):\n // Parent is 'text-opposite' (Border is white).\n // Children must also be 'text-opposite' (White text) to show on dark background.\n variant: LinkVariant.BUTTON_OUTLINED,\n color: LinkColor.TEXT_INVERSE,\n class: 'text-text-opposite *:text-text-opposite',\n },\n\n // Min height and padding for button variants\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n size: LinkSize.SM,\n class: 'min-h-7 px-3 max-md:py-1',\n },\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n size: LinkSize.MD,\n class: 'min-h-8 px-6 max-md:py-2',\n },\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n size: LinkSize.LG,\n class: 'min-h-10 px-8 max-md:py-3',\n },\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n size: LinkSize.XL,\n class: 'min-h-11 px-10 max-md:py-4',\n },\n // Ring color variants\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n color: LinkColor.PRIMARY,\n class: 'ring-primary/20',\n },\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n color: LinkColor.SECONDARY,\n class: 'ring-secondary/20',\n },\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n color: LinkColor.DESTRUCTIVE,\n class: 'ring-destructive/20',\n },\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n color: LinkColor.NEUTRAL,\n class: 'ring-neutral/20',\n },\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n color: LinkColor.LIGHT,\n class: 'ring-white/20',\n },\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n color: LinkColor.DARK,\n class: 'ring-neutral-800/20',\n },\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n color: LinkColor.TEXT,\n class: 'ring-text/20',\n },\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n color: LinkColor.TEXT_INVERSE,\n class: 'ring-text-opposite/20',\n },\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n color: LinkColor.ERROR,\n class: 'ring-error/20',\n },\n {\n variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],\n color: LinkColor.SUCCESS,\n class: 'ring-success/20',\n },\n ],\n\n defaultVariants: {\n variant: LinkVariant.DEFAULT,\n roundedSize: LinkRoundedSize.MD,\n underlined: LinkUnderlined.DEFAULT,\n size: LinkSize.MD,\n },\n }\n);\n\nexport type LinkProps = DetailedHTMLProps<\n AnchorHTMLAttributes<HTMLAnchorElement>,\n HTMLAnchorElement\n> &\n VariantProps<typeof linkVariants> & {\n label: string;\n isExternalLink?: boolean;\n isPageSection?: boolean;\n isActive?: boolean;\n locale?: LocalesValues;\n };\n\nexport const checkIsExternalLink = ({\n href,\n isExternalLink: isExternalLinkProp,\n}: LinkProps): boolean => {\n const isValidHref = typeof href === 'string' && href.trim() !== '';\n const isExternalLink =\n isExternalLinkProp === true ||\n (typeof isExternalLinkProp === 'undefined' &&\n isValidHref &&\n /^https?:\\/\\//.test(href));\n\n return isExternalLink;\n};\n\nexport const isTextChildren = (children: ReactNode): boolean => {\n if (typeof children === 'string' || typeof children === 'number') {\n return true;\n }\n if (Array.isArray(children)) {\n return children.every(isTextChildren);\n }\n if (isValidElement(children)) {\n return isTextChildren(\n (children.props as { children?: ReactNode }).children\n );\n }\n return false;\n};\n\nexport const Link: FC<LinkProps> = (props) => {\n const {\n variant = LinkVariant.DEFAULT,\n color = LinkColor.CUSTOM,\n roundedSize,\n children,\n label,\n className,\n isActive,\n underlined,\n locale,\n size,\n isExternalLink: isExternalLinkProp,\n isPageSection: isPageSectionProp,\n href: hrefProp,\n ...otherProps\n } = props;\n\n const isExternalLink = isExternalLinkProp ?? checkIsExternalLink(props);\n const isPageSection = isPageSectionProp ?? hrefProp?.startsWith('#') ?? false;\n\n const isChildrenString = isTextChildren(children);\n const isButton =\n variant === LinkVariant.BUTTON || variant === LinkVariant.BUTTON_OUTLINED;\n\n const rel = isExternalLink ? 'noopener noreferrer nofollow' : undefined;\n\n const target = isExternalLink ? '_blank' : '_self';\n\n const href =\n locale && hrefProp && !isExternalLink && !isPageSection\n ? getLocalizedUrl(hrefProp, locale)\n : hrefProp;\n\n return (\n <a\n href={href}\n aria-label={label}\n rel={rel}\n target={target}\n aria-current={isActive ? 'page' : undefined}\n suppressHydrationWarning\n className={cn(\n linkVariants({\n variant,\n color,\n roundedSize,\n underlined,\n size,\n className,\n })\n )}\n {...otherProps}\n >\n {isButton && isChildrenString ? <span>{children}</span> : children}\n\n {isExternalLink && isChildrenString && (\n <ExternalLink className=\"ml-2 inline-block size-4\" />\n )}\n {isPageSection && <MoveRight className=\"ml-2 inline-block size-4\" />}\n </a>\n );\n};\n"],"mappings":"ySAgBA,IAAY,EAAL,SAAA,EAAA,OACL,GAAA,QAAA,UACA,EAAA,eAAA,iBACA,EAAA,OAAA,SACA,EAAA,gBAAA,kBACA,EAAA,UAAA,kBACD,CAKW,EAAL,SAAA,EAAA,OACL,GAAA,QAAA,UACA,EAAA,UAAA,YACA,EAAA,YAAA,cACA,EAAA,QAAA,UACA,EAAA,MAAA,QACA,EAAA,KAAA,OACA,EAAA,KAAA,OACA,EAAA,aAAA,eACA,EAAA,MAAA,QACA,EAAA,QAAA,UACA,EAAA,OAAA,eACD,CAEW,EAAL,SAAA,EAAA,OACL,GAAA,KAAA,OACA,EAAA,GAAA,KACA,EAAA,GAAA,KACA,EAAA,GAAA,KACA,EAAA,GAAA,KACA,EAAA,OAAA,MACA,EAAA,SAAA,MACA,EAAA,KAAA,aACD,CAEW,EAAL,SAAA,EAAA,OACL,GAAA,GAAA,KACA,EAAA,GAAA,KACA,EAAA,GAAA,KACA,EAAA,GAAA,KACA,EAAA,OAAA,eACD,CAEW,EAAL,SAAA,EAAA,OACL,GAAA,QAAA,UACA,EAAA,KAAA,OACA,EAAA,MAAA,cACD,CAED,MAAa,EAAe,EAC1B,gHACA,CACE,SAAU,CACR,QAAS,EACN,GAAG,EAAY,WACd,2LACD,GAAG,EAAY,kBACd,+FAED,G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L,MAAM,QAAQ,EAAS,CAClB,EAAS,MAAM,EAAe,CAEnC,EAAe,EAAS,CACnB,EACJ,EAAS,MAAmC,SAC9C,CAEI,GAGI,EAAuB,GAAU,CAC5C,GAAM,CACJ,UAAU,EAAY,QACtB,QAAQ,EAAU,OAClB,cACA,WACA,QACA,YACA,WACA,aACA,SACA,OACA,eAAgB,EAChB,cAAe,EACf,KAAM,EACN,GAAG,GACD,EAEE,EAAiB,GAAsB,EAAoB,EAAM,CACjE,EAAgB,GAAqB,GAAU,WAAW,IAAI,EAAI,GAElE,EAAmB,EAAe,EAAS,CAC3C,EACJ,IAAY,EAAY,QAAU,IAAY,EAAY,gBAEtD,EAAM,EAAiB,+BAAiC,IAAA,GAExD,EAAS,EAAiB,SAAW,QAO3C,OACE,EAAC,IAAD,CACE,KANF,GAAU,GAAY,CAAC,GAAkB,CAAC,EACtC,EAAgB,EAAU,EAAO,CACjC,EAKF,aAAY,EACP,MACG,SACR,eAAc,EAAW,OAAS,IAAA,GAClC,yBAAA,GACA,UAAW,EACT,EAAa,CACX,UACA,QACA,cACA,aACA,OACA,YACD,CAAC,CACH,CACD,GAAI,WAjBN,CAmBG,GAAY,EAAmB,EAAC,OAAD,CAAO,WAAgB,CAAA,CAAG,EAEzD,GAAkB,GACjB,EAAC,EAAD,CAAc,UAAU,2BAA6B,CAAA,CAEtD,GAAiB,EAAC,EAAD,CAAW,UAAU,2BAA6B,CAAA,CAClE"}
@@ -1,2 +1,2 @@
1
- "use client";import{Container as e}from"../Container/index.mjs";import{Button as t,ButtonColor as n,ButtonSize as r,ButtonTextAlign as i,ButtonVariant as a}from"../Button/Button.mjs";import{Input as o}from"../Input/Input.mjs";import{usePersistedStore as s}from"../../hooks/usePersistedStore.mjs";import{DropDown as c}from"../DropDown/index.mjs";import{SwitchSelector as l,SwitchSelectorColor as u,SwitchSelectorSize as d}from"../SwitchSelector/index.mjs";import{useLocaleSwitcherContent as f}from"./LocaleSwitcherContentContext.mjs";import{Check as p,Globe as m,MoveVertical as h}from"lucide-react";import{useMemo as g,useRef as _,useState as v}from"react";import{Fragment as y,jsx as b,jsxs as x}from"react/jsx-runtime";import{useIntlayer as S,useLocale as C}from"react-intlayer";import{getHTMLTextDir as w,getLocaleName as T}from"@intlayer/core/localization";import{Locales as E}from"@intlayer/types";import D from"fuse.js";const O=`locale-switcher-content`,k=({panelProps:k,isMultilingual:A=!0})=>{let{switchTo:j,searchInput:M,localeSwitcherLabel:N,languageListLabel:P,seeAllLocalesSwitch:F}=S(`locale-switcher-content`),I=_(null),{locale:L}=C(),{availableLocales:R,selectedLocales:z,setSelectedLocales:B}=f(),V=g(()=>R.map(e=>({locale:e,englishName:T(e,E.ENGLISH),currentLocaleName:T(e,L),ownLocaleName:T(e)})),[R,L]),[H,U]=v(``),[W,G]=s(`locale-content-selector-see-all-locales`,!1),K=g(()=>new D(V,{keys:[{name:`ownLocaleName`,weight:.4},{name:`englishName`,weight:.2},{name:`currentLocaleName`,weight:.2},{name:`locale`,weight:.2}],threshold:.02}),[V]),q=g(()=>H?K.search(H).map(e=>e.item):V,[H,V,K]),J=e=>{A?z.includes(e)?z.length>1&&B(t=>t.filter(t=>t!==e)):B(t=>[...t,e]):B([e])},Y=e=>{G(e),B(e?R:[L])};return b(`div`,{className:`rounded-xl border border-text text-text transition-colors`,children:x(c,{identifier:O,children:[b(c.Trigger,{identifier:O,label:N.value,className:`p-0!`,roundedSize:`3xl`,children:x(`div`,{className:`flex w-full items-center justify-between`,children:[b(`div`,{className:`px-2 py-1`,children:b(m,{size:16})}),b(h,{className:`self-center`,size:16})]})}),b(c.Panel,{identifier:O,isOverable:!0,isFocusable:!0,className:`right-0 left-auto`,...k,children:x(e,{className:`max-h-[60vh] min-w-28`,separator:`y`,role:`listbox`,transparency:`xs`,border:!0,roundedSize:`2xl`,borderColor:`text`,"aria-label":P.value,children:[A&&b(`div`,{className:`m-auto p-2`,children:b(l,{defaultValue:W,onChange:Y,color:u.TEXT,size:d.SM,className:`!w-60`,choices:[{content:F.true.value,value:!0},{content:F.false.value,value:!1}]})}),!(A&&W)&&x(y,{children:[b(`div`,{className:`p-3`,children:b(o,{type:`search`,"aria-label":M.ariaLabel.value,placeholder:M.placeholder.value,onChange:e=>U(e.target.value),ref:I})}),b(`ol`,{className:`divide-y divide-dashed divide-text/20 overflow-y-auto p-1`,children:q.map(({locale:e,currentLocaleName:o,ownLocaleName:s})=>b(`li`,{className:`px-1.5 py-1`,children:b(t,{onClick:()=>J(e),label:`${j} ${o}`,disabled:!(R??R).includes(e),isActive:z.includes(e),variant:a.HOVERABLE,color:n.TEXT,isFullWidth:!0,textAlign:i.LEFT,size:r.SM,children:x(`div`,{className:`flex flex-row items-center justify-between gap-3 px-2 py-1`,children:[A&&b(`div`,{className:`w-4`,children:z.includes(e)&&b(p,{className:`size-full`})}),x(`div`,{className:`flex flex-1 flex-row items-center justify-between gap-3 px-2 py-1`,children:[x(`div`,{className:`flex flex-col text-nowrap`,children:[b(`span`,{dir:w(e),lang:e,children:s}),b(`span`,{className:`text-neutral text-xs`,children:o})]}),b(`span`,{className:`text-neutral text-sm`,children:e.toUpperCase()})]})]})})},e))})]})]})})]})})};export{k as LocaleSwitcherContent};
1
+ "use client";import{Container as e}from"../Container/index.mjs";import{Button as t,ButtonColor as n,ButtonSize as r,ButtonTextAlign as i,ButtonVariant as a}from"../Button/Button.mjs";import{Input as o}from"../Input/Input.mjs";import{usePersistedStore as s}from"../../hooks/usePersistedStore.mjs";import{DropDown as c}from"../DropDown/index.mjs";import{SwitchSelector as l,SwitchSelectorColor as u,SwitchSelectorSize as d}from"../SwitchSelector/index.mjs";import{useLocaleSwitcherContent as f}from"./LocaleSwitcherContentContext.mjs";import{useMemo as p,useRef as m,useState as h}from"react";import{Check as g,Globe as _,MoveVertical as v}from"lucide-react";import{Fragment as y,jsx as b,jsxs as x}from"react/jsx-runtime";import{useIntlayer as S,useLocale as C}from"react-intlayer";import{getHTMLTextDir as w,getLocaleName as T}from"@intlayer/core/localization";import*as E from"@intlayer/types/locales";import D from"fuse.js";const O=`locale-switcher-content`,k=({panelProps:k,isMultilingual:A=!0})=>{let{switchTo:j,searchInput:M,localeSwitcherLabel:N,languageListLabel:P,seeAllLocalesSwitch:F}=S(`locale-switcher-content`),I=m(null),{locale:L}=C(),{availableLocales:R,selectedLocales:z,setSelectedLocales:B}=f(),V=p(()=>R.map(e=>({locale:e,englishName:T(e,E.ENGLISH),currentLocaleName:T(e,L),ownLocaleName:T(e)})),[R,L]),[H,U]=h(``),[W,G]=s(`locale-content-selector-see-all-locales`,!1),K=p(()=>new D(V,{keys:[{name:`ownLocaleName`,weight:.4},{name:`englishName`,weight:.2},{name:`currentLocaleName`,weight:.2},{name:`locale`,weight:.2}],threshold:.02}),[V]),q=p(()=>H?K.search(H).map(e=>e.item):V,[H,V,K]),J=e=>{A?z.includes(e)?z.length>1&&B(t=>t.filter(t=>t!==e)):B(t=>[...t,e]):B([e])},Y=e=>{G(e),B(e?R:[L])};return b(`div`,{className:`rounded-xl border border-text text-text transition-colors`,children:x(c,{identifier:O,children:[b(c.Trigger,{identifier:O,label:N.value,className:`p-0!`,roundedSize:`3xl`,children:x(`div`,{className:`flex w-full items-center justify-between`,children:[b(`div`,{className:`px-2 py-1`,children:b(_,{size:16})}),b(v,{className:`self-center`,size:16})]})}),b(c.Panel,{identifier:O,isOverable:!0,isFocusable:!0,className:`right-0 left-auto`,...k,children:x(e,{className:`max-h-[60vh] min-w-28`,separator:`y`,role:`listbox`,transparency:`xs`,border:!0,roundedSize:`2xl`,borderColor:`text`,"aria-label":P.value,children:[A&&b(`div`,{className:`m-auto p-2`,children:b(l,{defaultValue:W,onChange:Y,color:u.TEXT,size:d.SM,className:`!w-60`,choices:[{content:F.true.value,value:!0},{content:F.false.value,value:!1}]})}),!(A&&W)&&x(y,{children:[b(`div`,{className:`p-3`,children:b(o,{type:`search`,"aria-label":M.ariaLabel.value,placeholder:M.placeholder.value,onChange:e=>U(e.target.value),ref:I})}),b(`ol`,{className:`divide-y divide-dashed divide-text/20 overflow-y-auto p-1`,children:q.map(({locale:e,currentLocaleName:o,ownLocaleName:s})=>b(`li`,{className:`px-1.5 py-1`,children:b(t,{onClick:()=>J(e),label:`${j} ${o}`,disabled:!(R??R).includes(e),isActive:z.includes(e),variant:a.HOVERABLE,color:n.TEXT,isFullWidth:!0,textAlign:i.LEFT,size:r.SM,children:x(`div`,{className:`flex flex-row items-center justify-between gap-3 px-2 py-1`,children:[A&&b(`div`,{className:`w-4`,children:z.includes(e)&&b(g,{className:`size-full`})}),x(`div`,{className:`flex flex-1 flex-row items-center justify-between gap-3 px-2 py-1`,children:[x(`div`,{className:`flex flex-col text-nowrap`,children:[b(`span`,{dir:w(e),lang:e,children:s}),b(`span`,{className:`text-neutral text-xs`,children:o})]}),b(`span`,{className:`text-neutral text-sm`,children:e.toUpperCase()})]})]})})},e))})]})]})})]})})};export{k as LocaleSwitcherContent};
2
2
  //# sourceMappingURL=LocaleSwitcherContent.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"LocaleSwitcherContent.mjs","names":[],"sources":["../../../../src/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.tsx"],"sourcesContent":["'use client';\n\nimport { usePersistedStore } from '@hooks/usePersistedStore';\nimport { getHTMLTextDir, getLocaleName } from '@intlayer/core/localization';\nimport { Locales, type LocalesValues } from '@intlayer/types';\nimport Fuse, { type IFuseOptions } from 'fuse.js';\nimport { Check, Globe, MoveVertical } from 'lucide-react';\nimport { type FC, useMemo, useRef, useState } from 'react';\nimport { useIntlayer, useLocale } from 'react-intlayer';\nimport {\n Button,\n ButtonColor,\n ButtonSize,\n ButtonTextAlign,\n ButtonVariant,\n} from '../Button';\nimport { Container } from '../Container';\nimport { DropDown, type PanelProps } from '../DropDown';\nimport { Input } from '../Input';\nimport {\n SwitchSelector,\n SwitchSelectorColor,\n SwitchSelectorSize,\n} from '../SwitchSelector';\nimport { useLocaleSwitcherContent } from './LocaleSwitcherContentContext';\n\nexport type LocaleSwitcherContentProps = {\n panelProps?: Omit<PanelProps, 'identifier'>;\n isMultilingual?: boolean;\n};\n\nconst DROPDOWN_IDENTIFIER = 'locale-switcher-content';\n\ntype MultilingualAvailableLocales = {\n locale: LocalesValues;\n englishName: string;\n currentLocaleName: string;\n ownLocaleName: string;\n};\n\nexport const LocaleSwitcherContent: FC<LocaleSwitcherContentProps> = ({\n panelProps,\n isMultilingual = true,\n}) => {\n const {\n switchTo,\n searchInput,\n localeSwitcherLabel,\n languageListLabel,\n seeAllLocalesSwitch,\n } = useIntlayer('locale-switcher-content');\n const inputRef = useRef<HTMLInputElement>(null);\n const { locale } = useLocale();\n const { availableLocales, selectedLocales, setSelectedLocales } =\n useLocaleSwitcherContent();\n\n // 1. Memoize the list construction so it doesn't rebuild every render\n const multilingualAvailableLocales: MultilingualAvailableLocales[] = useMemo(\n () =>\n availableLocales.map((localeEl) => {\n const englishName = getLocaleName(localeEl, Locales.ENGLISH);\n const currentLocaleName = getLocaleName(localeEl, locale);\n const ownLocaleName = getLocaleName(localeEl);\n return {\n locale: localeEl,\n englishName,\n currentLocaleName,\n ownLocaleName,\n };\n }),\n [availableLocales, locale]\n );\n\n // 2. State for Search Query only (Source of Truth)\n const [searchQuery, setSearchQuery] = useState('');\n\n const [seeAllLocales, setSeeAllLocales] = usePersistedStore(\n 'locale-content-selector-see-all-locales',\n false\n );\n\n // 3. Memoize Fuse instance\n const fuse = useMemo(() => {\n const fuseOptions: IFuseOptions<MultilingualAvailableLocales> = {\n keys: [\n { name: 'ownLocaleName', weight: 0.4 },\n { name: 'englishName', weight: 0.2 },\n { name: 'currentLocaleName', weight: 0.2 },\n { name: 'locale', weight: 0.2 },\n ],\n threshold: 0.02,\n };\n return new Fuse(multilingualAvailableLocales, fuseOptions);\n }, [multilingualAvailableLocales]);\n\n // 4. Derive results from Search Query\n const results = useMemo(() => {\n if (!searchQuery) {\n return multilingualAvailableLocales;\n }\n return fuse.search(searchQuery).map((result) => result.item);\n }, [searchQuery, multilingualAvailableLocales, fuse]);\n\n const handleClickLocale = (localeItem: LocalesValues) => {\n if (isMultilingual) {\n if (selectedLocales.includes(localeItem)) {\n if (selectedLocales.length > 1) {\n setSelectedLocales((prev) => prev.filter((el) => el !== localeItem));\n }\n } else {\n setSelectedLocales((prev) => [...prev, localeItem]);\n }\n } else {\n setSelectedLocales([localeItem]);\n }\n };\n\n const handleSeeAllLocales = (value: boolean) => {\n setSeeAllLocales(value);\n\n if (value) {\n setSelectedLocales(availableLocales);\n } else {\n setSelectedLocales([locale]);\n }\n };\n\n return (\n <div className=\"rounded-xl border border-text text-text transition-colors\">\n <DropDown identifier={DROPDOWN_IDENTIFIER}>\n <DropDown.Trigger\n identifier={DROPDOWN_IDENTIFIER}\n label={localeSwitcherLabel.value}\n className=\"p-0!\"\n roundedSize=\"3xl\"\n >\n <div className=\"flex w-full items-center justify-between\">\n <div className=\"px-2 py-1\">\n <Globe size={16} />\n </div>\n <MoveVertical className=\"self-center\" size={16} />\n </div>\n </DropDown.Trigger>\n\n <DropDown.Panel\n identifier={DROPDOWN_IDENTIFIER}\n isOverable\n isFocusable\n className=\"right-0 left-auto\"\n {...panelProps}\n >\n <Container\n className=\"max-h-[60vh] min-w-28\"\n separator=\"y\"\n role=\"listbox\"\n transparency=\"xs\"\n border\n roundedSize=\"2xl\"\n borderColor=\"text\"\n aria-label={languageListLabel.value}\n >\n {isMultilingual && (\n <div className=\"m-auto p-2\">\n <SwitchSelector\n defaultValue={seeAllLocales} // Ensure this uses the persisted state\n onChange={handleSeeAllLocales}\n color={SwitchSelectorColor.TEXT}\n size={SwitchSelectorSize.SM}\n className=\"!w-60\"\n choices={[\n {\n content: seeAllLocalesSwitch.true.value,\n value: true,\n },\n {\n content: seeAllLocalesSwitch.false.value,\n value: false,\n },\n ]}\n />\n </div>\n )}\n\n {!(isMultilingual && seeAllLocales) && (\n <>\n <div className=\"p-3\">\n <Input\n type=\"search\"\n aria-label={searchInput.ariaLabel.value}\n placeholder={searchInput.placeholder.value}\n // Update search query state directly\n onChange={(e) => setSearchQuery(e.target.value)}\n ref={inputRef}\n />\n </div>\n <ol className=\"divide-y divide-dashed divide-text/20 overflow-y-auto p-1\">\n {results.map(\n ({\n locale: localeItem,\n currentLocaleName,\n ownLocaleName,\n }) => (\n <li className=\"px-1.5 py-1\" key={localeItem}>\n <Button\n onClick={() => handleClickLocale(localeItem)}\n label={`${switchTo} ${currentLocaleName}`}\n disabled={\n !(availableLocales ?? availableLocales).includes(\n localeItem\n )\n }\n isActive={selectedLocales.includes(localeItem)}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.TEXT}\n isFullWidth\n textAlign={ButtonTextAlign.LEFT}\n size={ButtonSize.SM}\n >\n <div className=\"flex flex-row items-center justify-between gap-3 px-2 py-1\">\n {isMultilingual && (\n <div className=\"w-4\">\n {selectedLocales.includes(localeItem) && (\n <Check className=\"size-full\" />\n )}\n </div>\n )}\n <div className=\"flex flex-1 flex-row items-center justify-between gap-3 px-2 py-1\">\n <div className=\"flex flex-col text-nowrap\">\n <span\n dir={getHTMLTextDir(localeItem)}\n lang={localeItem}\n >\n {ownLocaleName}\n </span>\n <span className=\"text-neutral text-xs\">\n {currentLocaleName}\n </span>\n </div>\n <span className=\"text-neutral text-sm\">\n {localeItem.toUpperCase()}\n </span>\n </div>\n </div>\n </Button>\n </li>\n )\n )}\n </ol>\n </>\n )}\n </Container>\n </DropDown.Panel>\n </DropDown>\n </div>\n );\n};\n"],"mappings":"85BA+BA,MAAM,EAAsB,0BASf,GAAyD,CACpE,aACA,iBAAiB,MACb,CACJ,GAAM,CACJ,WACA,cACA,sBACA,oBACA,uBACE,EAAY,0BAA0B,CACpC,EAAW,EAAyB,KAAK,CACzC,CAAE,UAAW,GAAW,CACxB,CAAE,mBAAkB,kBAAiB,sBACzC,GAA0B,CAGtB,EAA+D,MAEjE,EAAiB,IAAK,IAIb,CACL,OAAQ,EACR,YALkB,EAAc,EAAU,EAAQ,QAAQ,CAM1D,kBALwB,EAAc,EAAU,EAAO,C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,WAEL,EACI,CAAA,CACP,EAAC,OAAD,CAAM,UAAU,gCACb,EACI,CAAA,CACH,GACN,EAAC,OAAD,CAAM,UAAU,gCACb,EAAW,aAAa,CACpB,CAAA,CACH,GACF,GACC,CAAA,CACN,CA1C4B,EA0C5B,CAER,CACE,CAAA,CACJ,CAAA,CAAA,CAEK,GACG,CAAA,CACR,GACP,CAAA"}
1
+ {"version":3,"file":"LocaleSwitcherContent.mjs","names":[],"sources":["../../../../src/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.tsx"],"sourcesContent":["'use client';\n\nimport { usePersistedStore } from '@hooks/usePersistedStore';\nimport { getHTMLTextDir, getLocaleName } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport * as Locales from '@intlayer/types/locales';\nimport Fuse, { type IFuseOptions } from 'fuse.js';\nimport { Check, Globe, MoveVertical } from 'lucide-react';\nimport { type FC, useMemo, useRef, useState } from 'react';\nimport { useIntlayer, useLocale } from 'react-intlayer';\nimport {\n Button,\n ButtonColor,\n ButtonSize,\n ButtonTextAlign,\n ButtonVariant,\n} from '../Button';\nimport { Container } from '../Container';\nimport { DropDown, type PanelProps } from '../DropDown';\nimport { Input } from '../Input';\nimport {\n SwitchSelector,\n SwitchSelectorColor,\n SwitchSelectorSize,\n} from '../SwitchSelector';\nimport { useLocaleSwitcherContent } from './LocaleSwitcherContentContext';\n\nexport type LocaleSwitcherContentProps = {\n panelProps?: Omit<PanelProps, 'identifier'>;\n isMultilingual?: boolean;\n};\n\nconst DROPDOWN_IDENTIFIER = 'locale-switcher-content';\n\ntype MultilingualAvailableLocales = {\n locale: LocalesValues;\n englishName: string;\n currentLocaleName: string;\n ownLocaleName: string;\n};\n\nexport const LocaleSwitcherContent: FC<LocaleSwitcherContentProps> = ({\n panelProps,\n isMultilingual = true,\n}) => {\n const {\n switchTo,\n searchInput,\n localeSwitcherLabel,\n languageListLabel,\n seeAllLocalesSwitch,\n } = useIntlayer('locale-switcher-content');\n const inputRef = useRef<HTMLInputElement>(null);\n const { locale } = useLocale();\n const { availableLocales, selectedLocales, setSelectedLocales } =\n useLocaleSwitcherContent();\n\n // 1. Memoize the list construction so it doesn't rebuild every render\n const multilingualAvailableLocales: MultilingualAvailableLocales[] = useMemo(\n () =>\n availableLocales.map((localeEl) => {\n const englishName = getLocaleName(localeEl, Locales.ENGLISH);\n const currentLocaleName = getLocaleName(localeEl, locale);\n const ownLocaleName = getLocaleName(localeEl);\n return {\n locale: localeEl,\n englishName,\n currentLocaleName,\n ownLocaleName,\n };\n }),\n [availableLocales, locale]\n );\n\n // 2. State for Search Query only (Source of Truth)\n const [searchQuery, setSearchQuery] = useState('');\n\n const [seeAllLocales, setSeeAllLocales] = usePersistedStore(\n 'locale-content-selector-see-all-locales',\n false\n );\n\n // 3. Memoize Fuse instance\n const fuse = useMemo(() => {\n const fuseOptions: IFuseOptions<MultilingualAvailableLocales> = {\n keys: [\n { name: 'ownLocaleName', weight: 0.4 },\n { name: 'englishName', weight: 0.2 },\n { name: 'currentLocaleName', weight: 0.2 },\n { name: 'locale', weight: 0.2 },\n ],\n threshold: 0.02,\n };\n return new Fuse(multilingualAvailableLocales, fuseOptions);\n }, [multilingualAvailableLocales]);\n\n // 4. Derive results from Search Query\n const results = useMemo(() => {\n if (!searchQuery) {\n return multilingualAvailableLocales;\n }\n return fuse.search(searchQuery).map((result) => result.item);\n }, [searchQuery, multilingualAvailableLocales, fuse]);\n\n const handleClickLocale = (localeItem: LocalesValues) => {\n if (isMultilingual) {\n if (selectedLocales.includes(localeItem)) {\n if (selectedLocales.length > 1) {\n setSelectedLocales((prev) => prev.filter((el) => el !== localeItem));\n }\n } else {\n setSelectedLocales((prev) => [...prev, localeItem]);\n }\n } else {\n setSelectedLocales([localeItem]);\n }\n };\n\n const handleSeeAllLocales = (value: boolean) => {\n setSeeAllLocales(value);\n\n if (value) {\n setSelectedLocales(availableLocales);\n } else {\n setSelectedLocales([locale]);\n }\n };\n\n return (\n <div className=\"rounded-xl border border-text text-text transition-colors\">\n <DropDown identifier={DROPDOWN_IDENTIFIER}>\n <DropDown.Trigger\n identifier={DROPDOWN_IDENTIFIER}\n label={localeSwitcherLabel.value}\n className=\"p-0!\"\n roundedSize=\"3xl\"\n >\n <div className=\"flex w-full items-center justify-between\">\n <div className=\"px-2 py-1\">\n <Globe size={16} />\n </div>\n <MoveVertical className=\"self-center\" size={16} />\n </div>\n </DropDown.Trigger>\n\n <DropDown.Panel\n identifier={DROPDOWN_IDENTIFIER}\n isOverable\n isFocusable\n className=\"right-0 left-auto\"\n {...panelProps}\n >\n <Container\n className=\"max-h-[60vh] min-w-28\"\n separator=\"y\"\n role=\"listbox\"\n transparency=\"xs\"\n border\n roundedSize=\"2xl\"\n borderColor=\"text\"\n aria-label={languageListLabel.value}\n >\n {isMultilingual && (\n <div className=\"m-auto p-2\">\n <SwitchSelector\n defaultValue={seeAllLocales} // Ensure this uses the persisted state\n onChange={handleSeeAllLocales}\n color={SwitchSelectorColor.TEXT}\n size={SwitchSelectorSize.SM}\n className=\"!w-60\"\n choices={[\n {\n content: seeAllLocalesSwitch.true.value,\n value: true,\n },\n {\n content: seeAllLocalesSwitch.false.value,\n value: false,\n },\n ]}\n />\n </div>\n )}\n\n {!(isMultilingual && seeAllLocales) && (\n <>\n <div className=\"p-3\">\n <Input\n type=\"search\"\n aria-label={searchInput.ariaLabel.value}\n placeholder={searchInput.placeholder.value}\n // Update search query state directly\n onChange={(e) => setSearchQuery(e.target.value)}\n ref={inputRef}\n />\n </div>\n <ol className=\"divide-y divide-dashed divide-text/20 overflow-y-auto p-1\">\n {results.map(\n ({\n locale: localeItem,\n currentLocaleName,\n ownLocaleName,\n }) => (\n <li className=\"px-1.5 py-1\" key={localeItem}>\n <Button\n onClick={() => handleClickLocale(localeItem)}\n label={`${switchTo} ${currentLocaleName}`}\n disabled={\n !(availableLocales ?? availableLocales).includes(\n localeItem\n )\n }\n isActive={selectedLocales.includes(localeItem)}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.TEXT}\n isFullWidth\n textAlign={ButtonTextAlign.LEFT}\n size={ButtonSize.SM}\n >\n <div className=\"flex flex-row items-center justify-between gap-3 px-2 py-1\">\n {isMultilingual && (\n <div className=\"w-4\">\n {selectedLocales.includes(localeItem) && (\n <Check className=\"size-full\" />\n )}\n </div>\n )}\n <div className=\"flex flex-1 flex-row items-center justify-between gap-3 px-2 py-1\">\n <div className=\"flex flex-col text-nowrap\">\n <span\n dir={getHTMLTextDir(localeItem)}\n lang={localeItem}\n >\n {ownLocaleName}\n </span>\n <span className=\"text-neutral text-xs\">\n {currentLocaleName}\n </span>\n </div>\n <span className=\"text-neutral text-sm\">\n {localeItem.toUpperCase()}\n </span>\n </div>\n </div>\n </Button>\n </li>\n )\n )}\n </ol>\n </>\n )}\n </Container>\n </DropDown.Panel>\n </DropDown>\n </div>\n );\n};\n"],"mappings":"85BAgCA,MAAM,EAAsB,0BASf,GAAyD,CACpE,aACA,iBAAiB,MACb,CACJ,GAAM,CACJ,WACA,cACA,sBACA,oBACA,uBACE,EAAY,0BAA0B,CACpC,EAAW,EAAyB,KAAK,CACzC,CAAE,UAAW,GAAW,CACxB,CAAE,mBAAkB,kBAAiB,sBACzC,GAA0B,CAGtB,EAA+D,MAEjE,EAAiB,IAAK,IAIb,CACL,OAAQ,EACR,YALkB,EAAc,EAAU,EAAQ,QAAQ,CAM1D,kBALwB,EAAc,EAAU,EAAO,CAMvD,cALoB,EAAc,EAAS,CAM5C,EACD,CACJ,CAAC,EAAkB,EAAO,CAC3B,CAGK,CAAC,EAAa,GAAkB,EAAS,GAAG,CAE5C,CAAC,EAAe,GAAoB,EACxC,0CACA,GACD,CAGK,EAAO,MAUJ,IAAI,EAAK,EATgD,CAC9D,KAAM,CACJ,CAAE,KAAM,gBAAiB,OAAQ,GAAK,CACtC,CAAE,KAAM,cAAe,OAAQ,GAAK,CACpC,CAAE,KAAM,oBAAqB,OAAQ,GAAK,CAC1C,CAAE,KAAM,SAAU,OAA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,MACnC,MAAO,GACR,CACF,CACD,CAAA,CACE,CAAA,CAGP,EAAE,GAAkB,IACnB,EAAA,EAAA,CAAA,SAAA,CACE,EAAC,MAAD,CAAK,UAAU,eACb,EAAC,EAAD,CACE,KAAK,SACL,aAAY,EAAY,UAAU,MAClC,YAAa,EAAY,YAAY,MAErC,SAAW,GAAM,EAAe,EAAE,OAAO,MAAM,CAC/C,IAAK,EACL,CAAA,CACE,CAAA,CACN,EAAC,KAAD,CAAI,UAAU,qEACX,EAAQ,KACN,CACC,OAAQ,EACR,oBACA,mBAEA,EAAC,KAAD,CAAI,UAAU,uBACZ,EAAC,EAAD,CACE,YAAe,EAAkB,EAAW,CAC5C,MAAO,GAAG,EAAS,GAAG,IACtB,SACE,EAAE,GAAoB,GAAkB,SACtC,EACD,CAEH,SAAU,EAAgB,SAAS,EAAW,CAC9C,QAAS,EAAc,UACvB,MAAO,EAAY,KACnB,YAAA,GACA,UAAW,EAAgB,KAC3B,KAAM,EAAW,YAEjB,EAAC,MAAD,CAAK,UAAU,sEAAf,CACG,GACC,EAAC,MAAD,CAAK,UAAU,eACZ,EAAgB,SAAS,EAAW,EACnC,EAAC,EAAD,CAAO,UAAU,YAAc,CAAA,CAE7B,CAAA,CAER,EAAC,MAAD,CAAK,UAAU,6EAAf,CACE,EAAC,MAAD,CAAK,UAAU,qCAAf,CACE,EAAC,OAAD,CACE,IAAK,EAAe,EAAW,CAC/B,KAAM,WAEL,EACI,CAAA,CACP,EAAC,OAAD,CAAM,UAAU,gCACb,EACI,CAAA,CACH,GACN,EAAC,OAAD,CAAM,UAAU,gCACb,EAAW,aAAa,CACpB,CAAA,CACH,GACF,GACC,CAAA,CACN,CA1C4B,EA0C5B,CAER,CACE,CAAA,CACJ,CAAA,CAAA,CAEK,GACG,CAAA,CACR,GACP,CAAA"}
@@ -1,2 +1,2 @@
1
- "use client";import{Container as e}from"../Container/index.mjs";import{Button as t,ButtonColor as n,ButtonTextAlign as r,ButtonVariant as i}from"../Button/Button.mjs";import{Input as a}from"../Input/Input.mjs";import{DropDown as o}from"../DropDown/index.mjs";import{MoveVertical as s}from"lucide-react";import{useCallback as c,useMemo as l,useRef as u,useState as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{useIntlayer as m}from"react-intlayer";import{getHTMLTextDir as h,getLocaleName as g}from"@intlayer/core/localization";import{Locales as _}from"@intlayer/types";import v from"fuse.js";const y=`locale-switcher`,b=({locale:b,localeList:x,availableLocales:S,fullLocaleName:C=!0,setLocale:w,panelProps:T})=>{let E=`Select a locale`,{switchTo:D,searchInput:O,languageListLabel:k,localeSwitcherLabel:A}=m(`locale-switcher`),j=u(null),M=l(()=>x.map(e=>({locale:e,englishName:g(e,_.ENGLISH),currentLocaleName:g(e,b),ownLocaleName:g(e)})),[x,b]),[N,P]=d(M),F=l(()=>new v(M,{keys:[{name:`ownLocaleName`,weight:.4},{name:`englishName`,weight:.2},{name:`currentLocaleName`,weight:.2},{name:`locale`,weight:.2}],threshold:.02}),[M]),I=c(e=>{P(e?F.search(e).map(e=>e.item):M)},[F,M]);return b&&(E=C?g(b):b.toUpperCase()),f(`nav`,{className:`rounded-xl border border-text text-text transition-colors`,"aria-label":A.value,children:p(o,{identifier:y,children:[f(o.Trigger,{identifier:y,children:p(`div`,{className:`flex w-full items-center justify-between`,children:[f(`div`,{className:`text-nowrap px-2`,children:E}),f(s,{className:`w-5 self-center`})]})}),f(o.Panel,{identifier:y,isOverable:!0,isFocusable:!0,...T,children:p(e,{className:`max-h-[80vh] min-w-28`,separator:`y`,role:`listbox`,transparency:`xs`,"aria-label":k.value,children:[f(`div`,{className:`p-3`,children:f(a,{type:`search`,"aria-label":O.ariaLabel.value,placeholder:O.placeholder.value,onChange:e=>I(e.target.value),ref:j})}),f(`ol`,{className:`divide-y divide-dashed divide-text/20 overflow-y-auto p-1`,children:N.map(({locale:e,currentLocaleName:a,ownLocaleName:o})=>f(`li`,{className:`px-1.5 py-1`,children:f(t,{onClick:()=>w(e),label:`${D} ${a}`,disabled:!(S??x).includes(e),isActive:b===e,variant:i.HOVERABLE,color:n.TEXT,isFullWidth:!0,textAlign:r.LEFT,children:p(`div`,{className:`flex flex-row items-center justify-between gap-3 px-2 py-1`,children:[p(`div`,{className:`flex flex-col text-nowrap`,children:[f(`span`,{dir:h(e),lang:e,suppressHydrationWarning:!0,children:o}),f(`span`,{className:`text-neutral text-xs`,suppressHydrationWarning:!0,children:a})]}),f(`span`,{className:`text-neutral text-sm`,children:e.toUpperCase()})]})})},e))})]})})]})})};export{b as LocaleSwitcher};
1
+ "use client";import{Container as e}from"../Container/index.mjs";import{Button as t,ButtonColor as n,ButtonTextAlign as r,ButtonVariant as i}from"../Button/Button.mjs";import{Input as a}from"../Input/Input.mjs";import{DropDown as o}from"../DropDown/index.mjs";import{useCallback as s,useMemo as c,useRef as l,useState as u}from"react";import{MoveVertical as d}from"lucide-react";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{useIntlayer as m}from"react-intlayer";import{getHTMLTextDir as h,getLocaleName as g}from"@intlayer/core/localization";import*as _ from"@intlayer/types/locales";import v from"fuse.js";const y=`locale-switcher`,b=({locale:b,localeList:x,availableLocales:S,fullLocaleName:C=!0,setLocale:w,panelProps:T})=>{let E=`Select a locale`,{switchTo:D,searchInput:O,languageListLabel:k,localeSwitcherLabel:A}=m(`locale-switcher`),j=l(null),M=c(()=>x.map(e=>({locale:e,englishName:g(e,_.ENGLISH),currentLocaleName:g(e,b),ownLocaleName:g(e)})),[x,b]),[N,P]=u(M),F=c(()=>new v(M,{keys:[{name:`ownLocaleName`,weight:.4},{name:`englishName`,weight:.2},{name:`currentLocaleName`,weight:.2},{name:`locale`,weight:.2}],threshold:.02}),[M]),I=s(e=>{P(e?F.search(e).map(e=>e.item):M)},[F,M]);return b&&(E=C?g(b):b.toUpperCase()),f(`nav`,{className:`rounded-xl border border-text text-text transition-colors`,"aria-label":A.value,children:p(o,{identifier:y,children:[f(o.Trigger,{identifier:y,children:p(`div`,{className:`flex w-full items-center justify-between`,children:[f(`div`,{className:`text-nowrap px-2`,children:E}),f(d,{className:`w-5 self-center`})]})}),f(o.Panel,{identifier:y,isOverable:!0,isFocusable:!0,...T,children:p(e,{className:`max-h-[80vh] min-w-28`,separator:`y`,role:`listbox`,transparency:`xs`,"aria-label":k.value,children:[f(`div`,{className:`p-3`,children:f(a,{type:`search`,"aria-label":O.ariaLabel.value,placeholder:O.placeholder.value,onChange:e=>I(e.target.value),ref:j})}),f(`ol`,{className:`divide-y divide-dashed divide-text/20 overflow-y-auto p-1`,children:N.map(({locale:e,currentLocaleName:a,ownLocaleName:o})=>f(`li`,{className:`px-1.5 py-1`,children:f(t,{onClick:()=>w(e),label:`${D} ${a}`,disabled:!(S??x).includes(e),isActive:b===e,variant:i.HOVERABLE,color:n.TEXT,isFullWidth:!0,textAlign:r.LEFT,children:p(`div`,{className:`flex flex-row items-center justify-between gap-3 px-2 py-1`,children:[p(`div`,{className:`flex flex-col text-nowrap`,children:[f(`span`,{dir:h(e),lang:e,suppressHydrationWarning:!0,children:o}),f(`span`,{className:`text-neutral text-xs`,suppressHydrationWarning:!0,children:a})]}),f(`span`,{className:`text-neutral text-sm`,children:e.toUpperCase()})]})})},e))})]})})]})})};export{b as LocaleSwitcher};
2
2
  //# sourceMappingURL=LocaleSwitcher.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"LocaleSwitcher.mjs","names":[],"sources":["../../../../src/components/LocaleSwitcherDropDown/LocaleSwitcher.tsx"],"sourcesContent":["'use client';\n\nimport { getHTMLTextDir, getLocaleName } from '@intlayer/core/localization';\nimport { type Locale, Locales } from '@intlayer/types';\nimport Fuse, { type IFuseOptions } from 'fuse.js';\nimport { MoveVertical } from 'lucide-react';\nimport { type FC, useCallback, useMemo, useRef, useState } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { Button, ButtonColor, ButtonTextAlign, ButtonVariant } from '../Button';\nimport { Container } from '../Container';\nimport { DropDown, type PanelProps } from '../DropDown';\nimport { Input } from '../Input';\n\nexport type LocaleSwitcherProps = {\n locale?: Locale;\n localeList: Locale[];\n availableLocales?: Locale[];\n fullLocaleName?: boolean;\n setLocale: (locale: Locale) => void;\n panelProps?: Omit<PanelProps, 'identifier'>;\n};\n\nconst DROPDOWN_IDENTIFIER = 'locale-switcher';\n\ntype MultilingualAvailableLocales = {\n locale: Locale;\n englishName: string;\n currentLocaleName: string;\n ownLocaleName: string;\n};\n\nexport const LocaleSwitcher: FC<LocaleSwitcherProps> = ({\n locale,\n localeList,\n availableLocales,\n fullLocaleName = true,\n setLocale,\n panelProps,\n}) => {\n let localeName = 'Select a locale';\n const { switchTo, searchInput, languageListLabel, localeSwitcherLabel } =\n useIntlayer('locale-switcher');\n const inputRef = useRef<HTMLInputElement>(null);\n\n const multilingualAvailableLocales: MultilingualAvailableLocales[] = useMemo(\n () =>\n localeList.map((localeEl) => {\n const englishName = getLocaleName(localeEl, Locales.ENGLISH);\n const currentLocaleName = getLocaleName(localeEl, locale);\n const ownLocaleName = getLocaleName(localeEl);\n return {\n locale: localeEl,\n englishName,\n currentLocaleName,\n ownLocaleName,\n };\n }),\n [localeList, locale]\n );\n\n const [results, setResults] = useState<MultilingualAvailableLocales[]>(\n multilingualAvailableLocales\n );\n\n // Create a new Fuse instance with the options and documentation data\n const fuse = useMemo(() => {\n const fuseOptions: IFuseOptions<MultilingualAvailableLocales> = {\n keys: [\n { name: 'ownLocaleName', weight: 0.4 },\n { name: 'englishName', weight: 0.2 },\n { name: 'currentLocaleName', weight: 0.2 },\n { name: 'locale', weight: 0.2 },\n ],\n threshold: 0.02, // Defines how fuzzy the matching should be (lower is more strict)\n };\n\n return new Fuse(multilingualAvailableLocales, fuseOptions);\n }, [multilingualAvailableLocales]);\n\n const handleSearch = useCallback(\n (searchQuery: string) => {\n if (searchQuery) {\n // Perform search on every input change\n const searchResults = fuse\n .search(searchQuery)\n .map((result) => result.item);\n setResults(searchResults);\n } else {\n setResults(multilingualAvailableLocales);\n }\n },\n [fuse, multilingualAvailableLocales]\n );\n\n if (locale) {\n localeName = fullLocaleName ? getLocaleName(locale) : locale.toUpperCase();\n }\n\n return (\n <nav\n className=\"rounded-xl border border-text text-text transition-colors\"\n aria-label={localeSwitcherLabel.value}\n >\n <DropDown identifier={DROPDOWN_IDENTIFIER}>\n <DropDown.Trigger identifier={DROPDOWN_IDENTIFIER}>\n <div className=\"flex w-full items-center justify-between\">\n <div className=\"text-nowrap px-2\">{localeName}</div>\n <MoveVertical className=\"w-5 self-center\" />\n </div>\n </DropDown.Trigger>\n\n <DropDown.Panel\n identifier={DROPDOWN_IDENTIFIER}\n isOverable\n isFocusable\n {...panelProps}\n >\n <Container\n className=\"max-h-[80vh] min-w-28\"\n separator=\"y\"\n role=\"listbox\"\n transparency=\"xs\"\n aria-label={languageListLabel.value}\n >\n <div className=\"p-3\">\n <Input\n type=\"search\"\n aria-label={searchInput.ariaLabel.value}\n placeholder={searchInput.placeholder.value}\n onChange={(e) => handleSearch(e.target.value)}\n ref={inputRef}\n />\n </div>\n <ol className=\"divide-y divide-dashed divide-text/20 overflow-y-auto p-1\">\n {results.map(\n ({ locale: localeItem, currentLocaleName, ownLocaleName }) => (\n <li className=\"px-1.5 py-1\" key={localeItem}>\n <Button\n onClick={() => setLocale(localeItem)}\n label={`${switchTo} ${currentLocaleName}`}\n disabled={\n !(availableLocales ?? localeList).includes(localeItem)\n }\n isActive={locale === localeItem}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.TEXT}\n isFullWidth\n textAlign={ButtonTextAlign.LEFT}\n >\n <div className=\"flex flex-row items-center justify-between gap-3 px-2 py-1\">\n <div className=\"flex flex-col text-nowrap\">\n <span\n dir={getHTMLTextDir(localeItem)}\n lang={localeItem}\n suppressHydrationWarning\n >\n {ownLocaleName}\n </span>\n <span\n className=\"text-neutral text-xs\"\n suppressHydrationWarning\n >\n {currentLocaleName}\n </span>\n </div>\n <span className=\"text-neutral text-sm\">\n {localeItem.toUpperCase()}\n </span>\n </div>\n </Button>\n </li>\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AS,MAAV,CACE,WAAY,EACZ,WAAA,GACA,YAAA,GACA,GAAI,WAEJ,EAAC,EAAD,CACE,UAAU,wBACV,UAAU,IACV,KAAK,UACL,aAAa,KACb,aAAY,EAAkB,eALhC,CAOE,EAAC,MAAD,CAAK,UAAU,eACb,EAAC,EAAD,CACE,KAAK,SACL,aAAY,EAAY,UAAU,MAClC,YAAa,EAAY,YAAY,MACrC,SAAW,GAAM,EAAa,EAAE,OAAO,MAAM,CAC7C,IAAK,EACL,CAAA,CACE,CAAA,CACN,EAAC,KAAD,CAAI,UAAU,qEACX,EAAQ,KACN,CAAE,OAAQ,EAAY,oBAAmB,mBACxC,EAAC,KAAD,CAAI,UAAU,uBACZ,EAAC,EAAD,CACE,YAAe,EAAU,EAAW,CACpC,MAAO,GAAG,EAAS,GAAG,IACtB,SACE,EAAE,GAAoB,GAAY,SAAS,EAAW,CAExD,SAAU,IAAW,EACrB,QAAS,EAAc,UACvB,MAAO,EAAY,KACnB,YAAA,GACA,UAAW,EAAgB,cAE3B,EAAC,MAAD,CAAK,UAAU,sEAAf,CACE,EAAC,MAAD,CAAK,UAAU,qCAAf,CACE,EAAC,OAAD,CACE,IAAK,EAAe,EAAW,CAC/B,KAAM,EACN,yBAAA,YAEC,EACI,CAAA,CACP,EAAC,OAAD,CACE,UAAU,uBACV,yBAAA,YAEC,EACI,CAAA,CACH,GACN,EAAC,OAAD,CAAM,UAAU,gCACb,EAAW,aAAa,CACpB,CAAA,CACH,GACC,CAAA,CACN,CAlC4B,EAkC5B,CAER,CACE,CAAA,CACK,GACG,CAAA,CACR,GACP,CAAA"}
1
+ {"version":3,"file":"LocaleSwitcher.mjs","names":[],"sources":["../../../../src/components/LocaleSwitcherDropDown/LocaleSwitcher.tsx"],"sourcesContent":["'use client';\n\nimport { getHTMLTextDir, getLocaleName } from '@intlayer/core/localization';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport * as Locales from '@intlayer/types/locales';\nimport Fuse, { type IFuseOptions } from 'fuse.js';\nimport { MoveVertical } from 'lucide-react';\nimport { type FC, useCallback, useMemo, useRef, useState } from 'react';\nimport { useIntlayer } from 'react-intlayer';\nimport { Button, ButtonColor, ButtonTextAlign, ButtonVariant } from '../Button';\nimport { Container } from '../Container';\nimport { DropDown, type PanelProps } from '../DropDown';\nimport { Input } from '../Input';\n\nexport type LocaleSwitcherProps = {\n locale?: Locale;\n localeList: Locale[];\n availableLocales?: Locale[];\n fullLocaleName?: boolean;\n setLocale: (locale: Locale) => void;\n panelProps?: Omit<PanelProps, 'identifier'>;\n};\n\nconst DROPDOWN_IDENTIFIER = 'locale-switcher';\n\ntype MultilingualAvailableLocales = {\n locale: Locale;\n englishName: string;\n currentLocaleName: string;\n ownLocaleName: string;\n};\n\nexport const LocaleSwitcher: FC<LocaleSwitcherProps> = ({\n locale,\n localeList,\n availableLocales,\n fullLocaleName = true,\n setLocale,\n panelProps,\n}) => {\n let localeName = 'Select a locale';\n const { switchTo, searchInput, languageListLabel, localeSwitcherLabel } =\n useIntlayer('locale-switcher');\n const inputRef = useRef<HTMLInputElement>(null);\n\n const multilingualAvailableLocales: MultilingualAvailableLocales[] = useMemo(\n () =>\n localeList.map((localeEl) => {\n const englishName = getLocaleName(localeEl, Locales.ENGLISH);\n const currentLocaleName = getLocaleName(localeEl, locale);\n const ownLocaleName = getLocaleName(localeEl);\n return {\n locale: localeEl,\n englishName,\n currentLocaleName,\n ownLocaleName,\n };\n }),\n [localeList, locale]\n );\n\n const [results, setResults] = useState<MultilingualAvailableLocales[]>(\n multilingualAvailableLocales\n );\n\n // Create a new Fuse instance with the options and documentation data\n const fuse = useMemo(() => {\n const fuseOptions: IFuseOptions<MultilingualAvailableLocales> = {\n keys: [\n { name: 'ownLocaleName', weight: 0.4 },\n { name: 'englishName', weight: 0.2 },\n { name: 'currentLocaleName', weight: 0.2 },\n { name: 'locale', weight: 0.2 },\n ],\n threshold: 0.02, // Defines how fuzzy the matching should be (lower is more strict)\n };\n\n return new Fuse(multilingualAvailableLocales, fuseOptions);\n }, [multilingualAvailableLocales]);\n\n const handleSearch = useCallback(\n (searchQuery: string) => {\n if (searchQuery) {\n // Perform search on every input change\n const searchResults = fuse\n .search(searchQuery)\n .map((result) => result.item);\n setResults(searchResults);\n } else {\n setResults(multilingualAvailableLocales);\n }\n },\n [fuse, multilingualAvailableLocales]\n );\n\n if (locale) {\n localeName = fullLocaleName ? getLocaleName(locale) : locale.toUpperCase();\n }\n\n return (\n <nav\n className=\"rounded-xl border border-text text-text transition-colors\"\n aria-label={localeSwitcherLabel.value}\n >\n <DropDown identifier={DROPDOWN_IDENTIFIER}>\n <DropDown.Trigger identifier={DROPDOWN_IDENTIFIER}>\n <div className=\"flex w-full items-center justify-between\">\n <div className=\"text-nowrap px-2\">{localeName}</div>\n <MoveVertical className=\"w-5 self-center\" />\n </div>\n </DropDown.Trigger>\n\n <DropDown.Panel\n identifier={DROPDOWN_IDENTIFIER}\n isOverable\n isFocusable\n {...panelProps}\n >\n <Container\n className=\"max-h-[80vh] min-w-28\"\n separator=\"y\"\n role=\"listbox\"\n transparency=\"xs\"\n aria-label={languageListLabel.value}\n >\n <div className=\"p-3\">\n <Input\n type=\"search\"\n aria-label={searchInput.ariaLabel.value}\n placeholder={searchInput.placeholder.value}\n onChange={(e) => handleSearch(e.target.value)}\n ref={inputRef}\n />\n </div>\n <ol className=\"divide-y divide-dashed divide-text/20 overflow-y-auto p-1\">\n {results.map(\n ({ locale: localeItem, currentLocaleName, ownLocaleName }) => (\n <li className=\"px-1.5 py-1\" key={localeItem}>\n <Button\n onClick={() => setLocale(localeItem)}\n label={`${switchTo} ${currentLocaleName}`}\n disabled={\n !(availableLocales ?? localeList).includes(localeItem)\n }\n isActive={locale === localeItem}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.TEXT}\n isFullWidth\n textAlign={ButtonTextAlign.LEFT}\n >\n <div className=\"flex flex-row items-center justify-between gap-3 px-2 py-1\">\n <div className=\"flex flex-col text-nowrap\">\n <span\n dir={getHTMLTextDir(localeItem)}\n lang={localeItem}\n suppressHydrationWarning\n >\n {ownLocaleName}\n </span>\n <span\n className=\"text-neutral text-xs\"\n suppressHydrationWarning\n >\n {currentLocaleName}\n </span>\n </div>\n <span className=\"text-neutral text-sm\">\n {localeItem.toUpperCase()}\n </span>\n </div>\n </Button>\n </li>\n )\n )}\n </ol>\n </Container>\n </DropDown.Panel>\n </DropDown>\n </nav>\n );\n};\n"],"mappings":"0mBAuBA,MAAM,EAAsB,kBASf,GAA2C,CACtD,SACA,aACA,mBACA,iBAAiB,GACjB,YACA,gBACI,CACJ,IAAI,EAAa,kBACX,CAAE,WAAU,cAAa,oBAAmB,uBAChD,EAAY,kBAAkB,CAC1B,EAAW,EAAyB,KAAK,CAEzC,EAA+D,MAEjE,EAAW,IAAK,IAIP,CACL,OAAQ,EACR,YALkB,EAAc,EAAU,EAAQ,QAAQ,CAM1D,kBALwB,EAAc,EAAU,EAAO,CAMvD,cALoB,EAAc,EAAS,CAM5C,EACD,CACJ,CAAC,EAAY,EAAO,CACrB,CAEK,CAAC,EAAS,GAAc,EAC5B,EACD,CAGK,EAAO,MAWJ,IAAI,EAAK,EAVgD,CAC9D,KAAM,CACJ,CAAE,KAAM,gBAAiB,OAAQ,GAAK,CACtC,CAAE,KAAM,cAAe,OAAQ,GAAK,CACpC,CAAE,KAAM,oBAAqB,OAAQ,GAAK,CAC1C,CAAE,KAAM,SAAU,OAAQ,GAAK,CAChC,CACD,UAAW,IACZ,CAEyD,CACzD,CAAC,EAA6B,CAAC,CAE5B,EAAe,EAClB,GAAwB,CAMrB,EALE,EAEoB,EACnB,OAAO,EAAY,CACnB,IAAK,GAAW,EAAO,KAAK,CAGpB,EAA6B,EAG5C,CAAC,EAAM,EAA6B,CACrC,CAMD,OAJI,IACF,EAAa,EAAiB,EAAc,EAAO,CAAG,EAAO,aAAa,EAI1E,EAAC,MAAD,CACE,UAAU,4DACV,aAAY,EAAoB,eAEhC,EAAC,EAAD,CAAU,WAAY,WAAtB,CACE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n.mjs";import{Link as t}from"../Link/Link.mjs";import{H1 as n,H2 as r,H3 as i,H4 as a,H5 as o,H6 as s}from"../Headers/index.mjs";import{CodeProvider as c}from"../IDE/CodeContext.mjs";import{Code as l}from"../IDE/Code.mjs";import{TabProvider as u}from"../Tab/TabContext.mjs";import{Tab as d}from"../Tab/Tab.mjs";import{Table as f}from"../Table/Table.mjs";import{jsx as p}from"react/jsx-runtime";import{renderMarkdown as m}from"react-intlayer";const h=c=>({components:{h1:e=>p(n,{isClickable:!0,className:`text-text`,...e}),h2:e=>p(r,{isClickable:!0,className:`mt-16 text-text`,...e}),h3:e=>p(i,{isClickable:!0,className:`mt-5 text-text`,...e}),h4:e=>p(a,{isClickable:!0,className:`mt-3 text-text`,...e}),h5:e=>p(o,{isClickable:!0,className:`mt-3 text-text`,...e}),h6:e=>p(s,{isClickable:!0,className:`mt-3 text-text`,...e}),strong:e=>p(`strong`,{className:`text-text`,...e}),code:({className:e,children:t,...n})=>{let r=String(t??``).replace(/\n$/,``);if(!e)return p(`code`,{className:`rounded-md border border-neutral/30 bg-card/60 box-decoration-clone px-1.5 py-0.5 font-mono text-sm`,children:r});let i=e?.replace(/lang(?:uage)?-/,``)||`plaintext`;return p(l,{...n,language:i,showHeader:!0,isDarkMode:c,children:r})},blockquote:({className:t,...n})=>p(`blockquote`,{className:e(`mt-5 gap-3 border-card border-l-4 pl-5 text-neutral`,`[&_strong]:text-neutral`,t),...n}),ul:({className:t,...n})=>p(`ul`,{className:e(`mt-5 flex list-disc flex-col gap-3 pl-5 marker:text-neutral/80`,t),...n}),ol:({className:t,...n})=>p(`ol`,{className:e(`mt-5 flex list-decimal flex-col gap-3 pl-5 marker:text-neutral/80`,t),...n}),img:({className:t,...n})=>p(`img`,{...n,alt:n.alt??``,loading:`lazy`,className:e(`max-h-[80vh] max-w-full rounded-md`,t),src:`${n.src}?raw=true`}),a:e=>p(t,{isExternalLink:e.href?.startsWith(`http`),underlined:!0,...e}),pre:e=>e.children,table:e=>p(f,{isRollable:!0,...e}),th:({className:t,...n})=>p(`th`,{className:e(`border-neutral border-b bg-neutral/10 p-4`,t),...n}),tr:({className:t,...n})=>p(`tr`,{className:e(`hover:/10 hover:bg-neutral/10`,t),...n}),td:({className:t,...n})=>p(`td`,{className:e(`border-neutral-500/50 border-b p-4`,t),...n}),hr:({className:t,...n})=>p(`hr`,{className:e(`mx-6 mt-16 text-neutral`,t),...n}),Tabs:e=>p(d,{...e,className:`rounded-xl border border-card`,headerClassName:`sticky rounded-xl top-24 z-5 bg-background/70 backdrop-blur overflow-x-auto`}),Tab:d.Item,Columns:({className:t,...n})=>p(`div`,{className:e(`flex gap-4 max-md:flex-col`,t),...n}),Column:({className:t,...n})=>p(`div`,{className:e(`flex-1`,t),...n})}}),g=({children:e,isDarkMode:n,locale:r,forceBlock:i,preserveFrontmatter:a,tagfilter:o,components:s,wrapper:d})=>{let f=h(n??!1);return p(c,{children:p(u,{children:m(e,{components:{...f.components,code:({className:e,children:t,...r})=>{let i=String(t??``).replace(/\n$/,``);if(!e)return p(`code`,{className:`rounded-md border border-neutral/30 bg-card/60 box-decoration-clone px-1.5 py-0.5 font-mono text-sm`,children:i});let a=e?.replace(/lang(?:uage)?-/,``)||`plaintext`;return p(l,{...r,language:a,showHeader:!0,isDarkMode:n,children:i})},a:e=>p(t,{isExternalLink:e.href?.startsWith(`http`),underlined:!0,locale:r,label:``,...e,color:`text`}),...s},wrapper:d??f.wrapper,forceBlock:i??f.forceBlock,preserveFrontmatter:a??f.preserveFrontmatter,tagfilter:o??f.tagfilter})})})};export{g as MarkdownRenderer,h as getIntlayerMarkdownOptions};
1
+ import{cn as e}from"../../utils/cn.mjs";import{Link as t}from"../Link/Link.mjs";import{H1 as n,H2 as r,H3 as i,H4 as a,H5 as o,H6 as s}from"../Headers/index.mjs";import{CodeProvider as c}from"../IDE/CodeContext.mjs";import{Code as l}from"../IDE/Code.mjs";import{TabProvider as u}from"../Tab/TabContext.mjs";import{Tab as d}from"../Tab/Tab.mjs";import{Table as f}from"../Table/Table.mjs";import{createContext as p,useContext as m}from"react";import{Fragment as h,jsx as g}from"react/jsx-runtime";import{renderMarkdown as _}from"react-intlayer";const v=p({}),y={h1:e=>g(n,{isClickable:!0,className:`text-text`,...e}),h2:e=>g(r,{isClickable:!0,className:`mt-16 text-text`,...e}),h3:e=>g(i,{isClickable:!0,className:`mt-5 text-text`,...e}),h4:e=>g(a,{isClickable:!0,className:`mt-3 text-text`,...e}),h5:e=>g(o,{isClickable:!0,className:`mt-3 text-text`,...e}),h6:e=>g(s,{isClickable:!0,className:`mt-3 text-text`,...e}),strong:e=>g(`strong`,{className:`text-text`,...e}),code:({className:e,children:t,...n})=>{let{isDarkMode:r}=m(v),i=String(t??``).replace(/\n$/,``);if(!e)return g(`code`,{className:`rounded-md border border-neutral/30 bg-card/60 box-decoration-clone px-1.5 py-0.5 font-mono text-sm`,children:i});let a=e?.replace(/lang(?:uage)?-/,``)||`plaintext`;return g(l,{...n,language:a,showHeader:!0,isDarkMode:r,children:i})},blockquote:({className:t,...n})=>g(`blockquote`,{className:e(`mt-5 gap-3 border-card border-l-4 pl-5 text-neutral [&_strong]:text-neutral`,t),...n}),ul:({className:t,...n})=>g(`ul`,{className:e(`mt-5 flex list-disc flex-col gap-3 pl-5 marker:text-neutral/80`,t),...n}),ol:({className:t,...n})=>g(`ol`,{className:e(`mt-5 flex list-decimal flex-col gap-3 pl-5 marker:text-neutral/80`,t),...n}),img:({className:t,alt:n,src:r,...i})=>g(`img`,{...i,alt:n??``,loading:`lazy`,className:e(`max-h-[80vh] max-w-full rounded-md`,t),src:`${r}?raw=true`}),a:e=>{let{locale:n}=m(v);return g(t,{isExternalLink:e.href?.startsWith(`http`),underlined:!0,locale:n,label:``,color:`text`,...e})},pre:e=>g(h,{children:e.children}),table:e=>g(f,{isRollable:!0,...e}),th:({className:t,...n})=>g(`th`,{className:e(`border-neutral border-b bg-neutral/10 p-4`,t),...n}),tr:({className:t,...n})=>g(`tr`,{className:e(`hover:/10 hover:bg-neutral/10`,t),...n}),td:({className:t,...n})=>g(`td`,{className:e(`border-neutral-500/50 border-b p-4`,t),...n}),hr:({className:t,...n})=>g(`hr`,{className:e(`mx-6 mt-16 text-neutral`,t),...n}),Tabs:e=>g(d,{...e,className:`rounded-xl border border-card`,headerClassName:`sticky rounded-xl top-24 z-5 bg-background/70 backdrop-blur overflow-x-auto`}),Tab:d.Item,Columns:({className:t,...n})=>g(`div`,{className:e(`flex gap-4 max-md:flex-col`,t),...n}),Column:({className:t,...n})=>g(`div`,{className:e(`flex-1`,t),...n})},b=e=>({components:y}),x=({children:e,isDarkMode:t=!1,locale:n,forceBlock:r,preserveFrontmatter:i,tagfilter:a,components:o,wrapper:s})=>{let l=_(e,{components:{...y,...o},wrapper:s,forceBlock:r,preserveFrontmatter:i,tagfilter:a});return g(v.Provider,{value:{isDarkMode:t,locale:n},children:g(c,{children:g(u,{children:l})})})};export{x as MarkdownRenderer,y as baseMarkdownComponents,b as getIntlayerMarkdownOptions};
2
2
  //# sourceMappingURL=MarkDownRender.mjs.map