@uzum-tech/ui 1.11.2 → 1.12.1

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 (547) hide show
  1. package/dist/index.js +54230 -49889
  2. package/dist/index.prod.js +4 -4
  3. package/es/_internal/close/src/Close.d.ts +2 -2
  4. package/es/_internal/icons/BurgerMenuIcon.d.ts +2 -0
  5. package/es/_internal/icons/BurgerMenuIcon.js +4 -0
  6. package/es/_internal/icons/Logout.d.ts +2 -0
  7. package/es/_internal/icons/Logout.js +4 -0
  8. package/es/_internal/icons/OzbekFlag.d.ts +2 -0
  9. package/es/_internal/icons/OzbekFlag.js +15 -0
  10. package/es/_internal/icons/RussiaFlag.d.ts +2 -0
  11. package/es/_internal/icons/RussiaFlag.js +11 -0
  12. package/es/_internal/icons/SendFilled.d.ts +2 -0
  13. package/es/_internal/icons/SendFilled.js +9 -0
  14. package/es/_internal/icons/index.d.ts +5 -0
  15. package/es/_internal/icons/index.js +5 -0
  16. package/es/_internal/loading/src/Loading.d.ts +1 -1
  17. package/es/_internal/safe-top-scrollbar/src/SafeTopScrollbar.d.ts +2 -2
  18. package/es/_internal/scrollbar/src/Scrollbar.d.ts +2 -2
  19. package/es/_internal/select-menu/src/SelectMenu.d.ts +7 -7
  20. package/es/_internal/selection/src/Selection.d.ts +13 -13
  21. package/es/_internal/skeleton/src/Skeleton.d.ts +1 -1
  22. package/es/_internal/typography/index.d.ts +1 -0
  23. package/es/_internal/typography/src/text.d.ts +42 -3
  24. package/es/_internal/typography/src/text.js +17 -4
  25. package/es/_internal/typography/src/variants.d.ts +105 -4
  26. package/es/_internal/typography/src/variants.js +84 -42
  27. package/es/_internal/typography/styles/dark.js +1 -1
  28. package/es/_internal/typography/styles/light.d.ts +1 -1
  29. package/es/_internal/typography/styles/light.js +1 -1
  30. package/es/_styles/common/dark.js +1 -1
  31. package/es/_styles/common/light.d.ts +1 -0
  32. package/es/_styles/common/light.js +1 -1
  33. package/es/affix/src/Affix.d.ts +3 -3
  34. package/es/alert/src/Alert.d.ts +3 -3
  35. package/es/anchor/src/AnchorAdapter.d.ts +5 -5
  36. package/es/auto-complete/src/AutoComplete.d.ts +3 -3
  37. package/es/avatar/src/Avatar.d.ts +1 -1
  38. package/es/avatar-group/src/AvatarGroup.d.ts +1 -1
  39. package/es/back-top/src/BackTop.d.ts +1 -1
  40. package/es/badge/src/Badge.d.ts +1 -1
  41. package/es/button/src/Button.d.ts +7 -7
  42. package/es/card/src/Card.d.ts +3 -3
  43. package/es/card-list/src/CardList.d.ts +2 -2
  44. package/es/card-list/src/CardListItem.d.ts +1 -1
  45. package/es/carousel/src/Carousel.d.ts +8 -8
  46. package/es/carousel/src/CarouselDots.d.ts +2 -2
  47. package/es/cascader/src/Cascader.d.ts +12 -12
  48. package/es/cascader/src/CascaderMenu.d.ts +1 -1
  49. package/es/cascader/src/CascaderSelectMenu.d.ts +1 -1
  50. package/es/chat/src/Chat.d.ts +464 -83
  51. package/es/chat/src/Chat.js +17 -2
  52. package/es/chat/src/ChatListItems.d.ts +497 -94
  53. package/es/chat/src/ChatListItems.js +1 -1
  54. package/es/chat/src/ChatMessages.d.ts +501 -94
  55. package/es/chat/src/ChatMessages.js +115 -22
  56. package/es/chat/src/ChatParts/MainArea.d.ts +7 -3
  57. package/es/chat/src/ChatParts/MainArea.js +110 -14
  58. package/es/chat/src/ChatParts/Sidebar.d.ts +64 -11
  59. package/es/chat/src/interface.d.ts +18 -0
  60. package/es/chat/src/interface.js +6 -0
  61. package/es/chat/src/styles/index.cssr.js +22 -1
  62. package/es/chat/styles/dark.d.ts +41 -8
  63. package/es/chat/styles/dark.js +6 -2
  64. package/es/chat/styles/light.d.ts +42 -8
  65. package/es/chat/styles/light.js +7 -2
  66. package/es/checkbox/src/Checkbox.d.ts +5 -5
  67. package/es/code/src/Code.d.ts +1 -1
  68. package/es/collapse/src/Collapse.d.ts +1 -1
  69. package/es/collapse-transition/src/CollapseTransition.d.ts +1 -1
  70. package/es/color-picker/src/ColorPicker.d.ts +3 -3
  71. package/es/components.d.ts +3 -0
  72. package/es/components.js +3 -0
  73. package/es/config-provider/src/ConfigProvider.d.ts +7 -1
  74. package/es/config-provider/src/ConfigProvider.js +83 -12
  75. package/es/config-provider/src/interface.d.ts +1 -1
  76. package/es/config-provider/src/internal-interface.d.ts +212 -33
  77. package/es/countdown/src/Countdown.d.ts +1 -1
  78. package/es/create.js +34 -3
  79. package/es/data-table/src/DataTable.d.ts +6 -6
  80. package/es/data-table/src/HeaderButton/RenderFilter.d.ts +1 -1
  81. package/es/date-picker/src/DatePicker.d.ts +4 -4
  82. package/es/date-picker/src/panel/date.d.ts +1 -1
  83. package/es/date-picker/src/panel/daterange.d.ts +1 -1
  84. package/es/date-picker/src/panel/datetime.d.ts +1 -1
  85. package/es/date-picker/src/panel/datetimerange.d.ts +1 -1
  86. package/es/date-picker/src/panel/panelMonth.d.ts +9 -9
  87. package/es/date-picker/src/panel/panelMonthContent.d.ts +1 -1
  88. package/es/date-picker/src/panel/panelYear.d.ts +9 -9
  89. package/es/date-picker/src/panel/panelYearContent.d.ts +1 -1
  90. package/es/descriptions/src/Descriptions.d.ts +3 -3
  91. package/es/dialog/src/Dialog.d.ts +1 -1
  92. package/es/dialog/src/DialogEnvironment.d.ts +3 -3
  93. package/es/dialog/src/DialogProvider.d.ts +31 -29
  94. package/es/dialog/src/dialogProps.d.ts +1 -1
  95. package/es/drawer/src/Drawer.d.ts +7 -7
  96. package/es/drawer/src/DrawerBodyWrapper.d.ts +2 -2
  97. package/es/dropdown/src/Dropdown.d.ts +15 -15
  98. package/es/dropdown/src/DropdownMenu.d.ts +2 -2
  99. package/es/dropdown/src/DropdownOption.d.ts +1 -1
  100. package/es/dynamic-input/src/DynamicInput.d.ts +1 -1
  101. package/es/dynamic-tags/src/DynamicTags.d.ts +2 -2
  102. package/es/empty/src/Empty.d.ts +1 -1
  103. package/es/flex/src/Flex.d.ts +1 -1
  104. package/es/form/src/FormItem.d.ts +3 -3
  105. package/es/form/src/FormItemCol.d.ts +2 -2
  106. package/es/form/src/FormItemGridItem.d.ts +3 -3
  107. package/es/form/src/FormItemRow.d.ts +2 -2
  108. package/es/form/src/utils.d.ts +1 -1
  109. package/es/gradient-text/src/GradientText.d.ts +2 -2
  110. package/es/grid/src/Grid.d.ts +3 -3
  111. package/es/grid/src/GridItem.d.ts +2 -2
  112. package/es/header/demos/mock.d.ts +2 -0
  113. package/es/header/demos/mock.js +235 -0
  114. package/es/header/index.d.ts +12 -0
  115. package/es/header/index.js +10 -0
  116. package/es/header/src/Header.d.ts +604 -0
  117. package/es/header/src/Header.js +320 -0
  118. package/es/header/src/HeaderActions.d.ts +120 -0
  119. package/es/header/src/HeaderActions.js +166 -0
  120. package/es/header/src/HeaderDesktopLayout.d.ts +25 -0
  121. package/es/header/src/HeaderDesktopLayout.js +24 -0
  122. package/es/header/src/HeaderMobileLayout.d.ts +25 -0
  123. package/es/header/src/HeaderMobileLayout.js +21 -0
  124. package/es/header/src/HeaderNavigation.d.ts +128 -0
  125. package/es/header/src/HeaderNavigation.js +172 -0
  126. package/es/header/src/HeaderSearchDesktop.d.ts +79 -0
  127. package/es/header/src/HeaderSearchDesktop.js +77 -0
  128. package/es/header/src/HeaderSearchMobile.d.ts +73 -0
  129. package/es/header/src/HeaderSearchMobile.js +126 -0
  130. package/es/header/src/HeaderSearchResults.d.ts +81 -0
  131. package/es/header/src/HeaderSearchResults.js +74 -0
  132. package/es/header/src/constants.d.ts +1 -0
  133. package/es/header/src/constants.js +1 -0
  134. package/es/header/src/interface.d.ts +58 -0
  135. package/es/header/src/interface.js +1 -0
  136. package/es/header/src/mobile/HeaderMobile.d.ts +218 -0
  137. package/es/header/src/mobile/HeaderMobile.js +241 -0
  138. package/es/header/src/styles/index.cssr.d.ts +6 -0
  139. package/es/header/src/styles/index.cssr.js +519 -0
  140. package/es/header/src/utils.d.ts +12 -0
  141. package/es/header/src/utils.js +47 -0
  142. package/es/header/styles/dark.d.ts +36 -0
  143. package/es/header/styles/dark.js +9 -0
  144. package/es/header/styles/index.d.ts +3 -0
  145. package/es/header/styles/index.js +2 -0
  146. package/es/header/styles/light.d.ts +72 -0
  147. package/es/header/styles/light.js +45 -0
  148. package/es/icon/src/Icon.d.ts +3 -0
  149. package/es/icon/src/Icon.js +3 -2
  150. package/es/icon-bar/index.d.ts +4 -0
  151. package/es/icon-bar/index.js +2 -0
  152. package/es/icon-bar/src/IconBar.d.ts +175 -0
  153. package/es/icon-bar/src/IconBar.js +57 -0
  154. package/es/icon-bar/src/IconBarItem.d.ts +163 -0
  155. package/es/icon-bar/src/IconBarItem.js +50 -0
  156. package/es/icon-bar/src/styles/index.cssr.d.ts +2 -0
  157. package/es/icon-bar/src/styles/index.cssr.js +62 -0
  158. package/es/icon-bar/styles/dark.d.ts +3 -0
  159. package/es/icon-bar/styles/dark.js +8 -0
  160. package/es/icon-bar/styles/index.d.ts +3 -0
  161. package/es/icon-bar/styles/index.js +2 -0
  162. package/es/icon-bar/styles/light.d.ts +19 -0
  163. package/es/icon-bar/styles/light.js +23 -0
  164. package/es/icon-wrapper/src/IconWrapper.d.ts +1 -1
  165. package/es/input/src/Input.d.ts +8 -8
  166. package/es/input-number/src/InputNumber.d.ts +3 -3
  167. package/es/input-otp/src/InputOtp.d.ts +1 -1
  168. package/es/layout/src/LayoutSider.d.ts +2 -2
  169. package/es/legacy-grid/src/Row.d.ts +1 -1
  170. package/es/legacy-transfer/src/Transfer.d.ts +2 -2
  171. package/es/list/src/List.d.ts +6 -6
  172. package/es/list/src/ListItem.d.ts +4 -4
  173. package/es/locales/common/arDZ.js +11 -1
  174. package/es/locales/common/deDE.js +11 -1
  175. package/es/locales/common/enGB.js +11 -1
  176. package/es/locales/common/enUS.d.ts +10 -0
  177. package/es/locales/common/enUS.js +11 -1
  178. package/es/locales/common/eo.js +11 -1
  179. package/es/locales/common/esAR.js +11 -1
  180. package/es/locales/common/faIR.js +11 -1
  181. package/es/locales/common/frFR.js +11 -1
  182. package/es/locales/common/idID.js +11 -1
  183. package/es/locales/common/itIT.js +11 -1
  184. package/es/locales/common/jaJP.js +11 -1
  185. package/es/locales/common/koKR.js +11 -1
  186. package/es/locales/common/nbNO.js +11 -1
  187. package/es/locales/common/nlNL.js +11 -1
  188. package/es/locales/common/plPL.js +11 -1
  189. package/es/locales/common/ptBR.js +11 -1
  190. package/es/locales/common/ruRU.js +11 -1
  191. package/es/locales/common/skSK.js +11 -1
  192. package/es/locales/common/svSE.js +11 -1
  193. package/es/locales/common/thTH.js +11 -1
  194. package/es/locales/common/trTR.js +11 -1
  195. package/es/locales/common/ukUA.js +11 -1
  196. package/es/locales/common/viVN.js +11 -1
  197. package/es/locales/common/zhCN.js +11 -1
  198. package/es/locales/common/zhTW.js +11 -1
  199. package/es/log/src/Log.d.ts +2 -2
  200. package/es/mention/src/Mention.d.ts +3 -3
  201. package/es/menu/src/Menu.d.ts +5 -5
  202. package/es/menu/src/MenuOption.d.ts +1 -1
  203. package/es/menu/src/MenuOptionContent.d.ts +1 -1
  204. package/es/menu/src/MenuOptionGroup.d.ts +1 -1
  205. package/es/menu/src/Submenu.d.ts +1 -1
  206. package/es/message/src/MessageProvider.d.ts +1 -1
  207. package/es/modal/src/BodyWrapper.d.ts +3 -3
  208. package/es/modal/src/Modal.d.ts +6 -6
  209. package/es/modal/src/presetProps.d.ts +1 -1
  210. package/es/modal-fullscreen/src/ModalFull.d.ts +2 -2
  211. package/es/notification/src/Notification.d.ts +2 -2
  212. package/es/notification/src/NotificationEnvironment.d.ts +1 -1
  213. package/es/notification/src/NotificationProvider.d.ts +9 -9
  214. package/es/number-animation/src/NumberAnimation.d.ts +2 -2
  215. package/es/pagination/src/Pagination.d.ts +1 -1
  216. package/es/popconfirm/src/Popconfirm.d.ts +8 -8
  217. package/es/popover/src/Popover.d.ts +8 -8
  218. package/es/popover/src/PopoverBody.d.ts +2 -2
  219. package/es/popselect/src/Popselect.d.ts +81 -81
  220. package/es/popselect/src/PopselectPanel.d.ts +4 -4
  221. package/es/progress/src/Circle.d.ts +1 -1
  222. package/es/progress/src/MultipleCircle.d.ts +1 -1
  223. package/es/progress/src/Progress.d.ts +4 -4
  224. package/es/qr-code/index.d.ts +2 -0
  225. package/es/qr-code/index.js +1 -0
  226. package/es/qr-code/src/QrCode.d.ts +171 -0
  227. package/es/qr-code/src/QrCode.js +229 -0
  228. package/es/qr-code/src/qrcodegen.d.ts +95 -0
  229. package/es/qr-code/src/qrcodegen.js +949 -0
  230. package/es/qr-code/src/styles/index.cssr.d.ts +2 -0
  231. package/es/qr-code/src/styles/index.cssr.js +8 -0
  232. package/es/qr-code/styles/dark.d.ts +3 -0
  233. package/es/qr-code/styles/dark.js +11 -0
  234. package/es/qr-code/styles/index.d.ts +3 -0
  235. package/es/qr-code/styles/index.js +2 -0
  236. package/es/qr-code/styles/light.d.ts +9 -0
  237. package/es/qr-code/styles/light.js +12 -0
  238. package/es/radio/src/Radio.d.ts +1 -1
  239. package/es/rate/src/Rate.d.ts +3 -3
  240. package/es/result/src/Result.d.ts +1 -1
  241. package/es/select/src/Select.d.ts +19 -19
  242. package/es/skeleton/src/Skeleton.d.ts +1 -1
  243. package/es/slider/src/Slider.d.ts +4 -4
  244. package/es/space/src/Space.d.ts +1 -1
  245. package/es/spin/src/Spin.d.ts +2 -2
  246. package/es/steps/src/Steps.d.ts +1 -1
  247. package/es/switch/src/Switch.d.ts +1 -1
  248. package/es/tabs/src/Tab.d.ts +1 -1
  249. package/es/tabs/src/Tabs.d.ts +4 -4
  250. package/es/tag/src/Tag.d.ts +2 -2
  251. package/es/tag/src/TagGroup.d.ts +1 -1
  252. package/es/theme-editor/src/ThemeEditor.d.ts +1 -0
  253. package/es/themes/dark.js +7 -1
  254. package/es/themes/light.js +7 -1
  255. package/es/time/src/Time.d.ts +1 -1
  256. package/es/time-picker/src/Panel.d.ts +1 -1
  257. package/es/time-picker/src/TimePicker.d.ts +5 -5
  258. package/es/timeline/src/TimelineItem.d.ts +1 -1
  259. package/es/tooltip/src/Tooltip.d.ts +8 -8
  260. package/es/transfer/src/Transfer.d.ts +3 -3
  261. package/es/tree/src/Tree.d.ts +18 -18
  262. package/es/tree/src/TreeNodeCheckbox.d.ts +1 -1
  263. package/es/tree-select/src/TreeSelect.d.ts +15 -15
  264. package/es/typography/index.d.ts +1 -0
  265. package/es/typography/src/create-header.d.ts +1 -1
  266. package/es/typography/src/headers.d.ts +6 -6
  267. package/es/typography/src/text.d.ts +44 -5
  268. package/es/upload/src/Upload.d.ts +11 -11
  269. package/es/upload/src/UploadFile.d.ts +1 -1
  270. package/es/version.d.ts +1 -1
  271. package/es/version.js +1 -1
  272. package/es/virtual-list/src/VirtualList.d.ts +2 -2
  273. package/es/watermark/src/Watermark.d.ts +7 -7
  274. package/lib/_internal/close/src/Close.d.ts +2 -2
  275. package/lib/_internal/icons/BurgerMenuIcon.d.ts +2 -0
  276. package/lib/_internal/icons/BurgerMenuIcon.js +6 -0
  277. package/lib/_internal/icons/Logout.d.ts +2 -0
  278. package/lib/_internal/icons/Logout.js +6 -0
  279. package/lib/_internal/icons/OzbekFlag.d.ts +2 -0
  280. package/lib/_internal/icons/OzbekFlag.js +17 -0
  281. package/lib/_internal/icons/RussiaFlag.d.ts +2 -0
  282. package/lib/_internal/icons/RussiaFlag.js +13 -0
  283. package/lib/_internal/icons/SendFilled.d.ts +2 -0
  284. package/lib/_internal/icons/SendFilled.js +11 -0
  285. package/lib/_internal/icons/index.d.ts +5 -0
  286. package/lib/_internal/icons/index.js +11 -1
  287. package/lib/_internal/loading/src/Loading.d.ts +1 -1
  288. package/lib/_internal/safe-top-scrollbar/src/SafeTopScrollbar.d.ts +2 -2
  289. package/lib/_internal/scrollbar/src/Scrollbar.d.ts +2 -2
  290. package/lib/_internal/select-menu/src/SelectMenu.d.ts +7 -7
  291. package/lib/_internal/selection/src/Selection.d.ts +13 -13
  292. package/lib/_internal/skeleton/src/Skeleton.d.ts +1 -1
  293. package/lib/_internal/typography/index.d.ts +1 -0
  294. package/lib/_internal/typography/src/text.d.ts +42 -3
  295. package/lib/_internal/typography/src/text.js +18 -5
  296. package/lib/_internal/typography/src/variants.d.ts +105 -4
  297. package/lib/_internal/typography/src/variants.js +87 -43
  298. package/lib/_internal/typography/styles/dark.js +2 -2
  299. package/lib/_internal/typography/styles/light.d.ts +1 -1
  300. package/lib/_internal/typography/styles/light.js +2 -2
  301. package/lib/_styles/common/dark.js +1 -1
  302. package/lib/_styles/common/light.d.ts +1 -0
  303. package/lib/_styles/common/light.js +1 -1
  304. package/lib/affix/src/Affix.d.ts +3 -3
  305. package/lib/alert/src/Alert.d.ts +3 -3
  306. package/lib/anchor/src/AnchorAdapter.d.ts +5 -5
  307. package/lib/auto-complete/src/AutoComplete.d.ts +3 -3
  308. package/lib/avatar/src/Avatar.d.ts +1 -1
  309. package/lib/avatar-group/src/AvatarGroup.d.ts +1 -1
  310. package/lib/back-top/src/BackTop.d.ts +1 -1
  311. package/lib/badge/src/Badge.d.ts +1 -1
  312. package/lib/button/src/Button.d.ts +7 -7
  313. package/lib/card/src/Card.d.ts +3 -3
  314. package/lib/card-list/src/CardList.d.ts +2 -2
  315. package/lib/card-list/src/CardListItem.d.ts +1 -1
  316. package/lib/carousel/src/Carousel.d.ts +8 -8
  317. package/lib/carousel/src/CarouselDots.d.ts +2 -2
  318. package/lib/cascader/src/Cascader.d.ts +12 -12
  319. package/lib/cascader/src/CascaderMenu.d.ts +1 -1
  320. package/lib/cascader/src/CascaderSelectMenu.d.ts +1 -1
  321. package/lib/chat/src/Chat.d.ts +464 -83
  322. package/lib/chat/src/Chat.js +17 -2
  323. package/lib/chat/src/ChatListItems.d.ts +497 -94
  324. package/lib/chat/src/ChatListItems.js +1 -1
  325. package/lib/chat/src/ChatMessages.d.ts +501 -94
  326. package/lib/chat/src/ChatMessages.js +113 -20
  327. package/lib/chat/src/ChatParts/MainArea.d.ts +7 -3
  328. package/lib/chat/src/ChatParts/MainArea.js +108 -12
  329. package/lib/chat/src/ChatParts/Sidebar.d.ts +64 -11
  330. package/lib/chat/src/interface.d.ts +18 -0
  331. package/lib/chat/src/interface.js +7 -1
  332. package/lib/chat/src/styles/index.cssr.js +22 -1
  333. package/lib/chat/styles/dark.d.ts +41 -8
  334. package/lib/chat/styles/dark.js +6 -2
  335. package/lib/chat/styles/light.d.ts +42 -8
  336. package/lib/chat/styles/light.js +7 -2
  337. package/lib/checkbox/src/Checkbox.d.ts +5 -5
  338. package/lib/code/src/Code.d.ts +1 -1
  339. package/lib/collapse/src/Collapse.d.ts +1 -1
  340. package/lib/collapse-transition/src/CollapseTransition.d.ts +1 -1
  341. package/lib/color-picker/src/ColorPicker.d.ts +3 -3
  342. package/lib/components.d.ts +3 -0
  343. package/lib/components.js +3 -0
  344. package/lib/config-provider/src/ConfigProvider.d.ts +7 -1
  345. package/lib/config-provider/src/ConfigProvider.js +81 -10
  346. package/lib/config-provider/src/interface.d.ts +1 -1
  347. package/lib/config-provider/src/internal-interface.d.ts +212 -33
  348. package/lib/countdown/src/Countdown.d.ts +1 -1
  349. package/lib/create.js +34 -3
  350. package/lib/data-table/src/DataTable.d.ts +6 -6
  351. package/lib/data-table/src/HeaderButton/RenderFilter.d.ts +1 -1
  352. package/lib/date-picker/src/DatePicker.d.ts +4 -4
  353. package/lib/date-picker/src/panel/date.d.ts +1 -1
  354. package/lib/date-picker/src/panel/daterange.d.ts +1 -1
  355. package/lib/date-picker/src/panel/datetime.d.ts +1 -1
  356. package/lib/date-picker/src/panel/datetimerange.d.ts +1 -1
  357. package/lib/date-picker/src/panel/panelMonth.d.ts +9 -9
  358. package/lib/date-picker/src/panel/panelMonthContent.d.ts +1 -1
  359. package/lib/date-picker/src/panel/panelYear.d.ts +9 -9
  360. package/lib/date-picker/src/panel/panelYearContent.d.ts +1 -1
  361. package/lib/descriptions/src/Descriptions.d.ts +3 -3
  362. package/lib/dialog/src/Dialog.d.ts +1 -1
  363. package/lib/dialog/src/DialogEnvironment.d.ts +3 -3
  364. package/lib/dialog/src/DialogProvider.d.ts +31 -29
  365. package/lib/dialog/src/dialogProps.d.ts +1 -1
  366. package/lib/drawer/src/Drawer.d.ts +7 -7
  367. package/lib/drawer/src/DrawerBodyWrapper.d.ts +2 -2
  368. package/lib/dropdown/src/Dropdown.d.ts +15 -15
  369. package/lib/dropdown/src/DropdownMenu.d.ts +2 -2
  370. package/lib/dropdown/src/DropdownOption.d.ts +1 -1
  371. package/lib/dynamic-input/src/DynamicInput.d.ts +1 -1
  372. package/lib/dynamic-tags/src/DynamicTags.d.ts +2 -2
  373. package/lib/empty/src/Empty.d.ts +1 -1
  374. package/lib/flex/src/Flex.d.ts +1 -1
  375. package/lib/form/src/FormItem.d.ts +3 -3
  376. package/lib/form/src/FormItemCol.d.ts +2 -2
  377. package/lib/form/src/FormItemGridItem.d.ts +3 -3
  378. package/lib/form/src/FormItemRow.d.ts +2 -2
  379. package/lib/form/src/utils.d.ts +1 -1
  380. package/lib/gradient-text/src/GradientText.d.ts +2 -2
  381. package/lib/grid/src/Grid.d.ts +3 -3
  382. package/lib/grid/src/GridItem.d.ts +2 -2
  383. package/lib/header/demos/mock.d.ts +2 -0
  384. package/lib/header/demos/mock.js +238 -0
  385. package/lib/header/index.d.ts +12 -0
  386. package/lib/header/index.js +48 -0
  387. package/lib/header/src/Header.d.ts +604 -0
  388. package/lib/header/src/Header.js +349 -0
  389. package/lib/header/src/HeaderActions.d.ts +120 -0
  390. package/lib/header/src/HeaderActions.js +172 -0
  391. package/lib/header/src/HeaderDesktopLayout.d.ts +25 -0
  392. package/lib/header/src/HeaderDesktopLayout.js +27 -0
  393. package/lib/header/src/HeaderMobileLayout.d.ts +25 -0
  394. package/lib/header/src/HeaderMobileLayout.js +24 -0
  395. package/lib/header/src/HeaderNavigation.d.ts +128 -0
  396. package/lib/header/src/HeaderNavigation.js +175 -0
  397. package/lib/header/src/HeaderSearchDesktop.d.ts +79 -0
  398. package/lib/header/src/HeaderSearchDesktop.js +83 -0
  399. package/lib/header/src/HeaderSearchMobile.d.ts +73 -0
  400. package/lib/header/src/HeaderSearchMobile.js +132 -0
  401. package/lib/header/src/HeaderSearchResults.d.ts +81 -0
  402. package/lib/header/src/HeaderSearchResults.js +77 -0
  403. package/lib/header/src/constants.d.ts +1 -0
  404. package/lib/header/src/constants.js +4 -0
  405. package/lib/header/src/interface.d.ts +58 -0
  406. package/lib/header/src/interface.js +2 -0
  407. package/lib/header/src/mobile/HeaderMobile.d.ts +218 -0
  408. package/lib/header/src/mobile/HeaderMobile.js +244 -0
  409. package/lib/header/src/styles/index.cssr.d.ts +6 -0
  410. package/lib/header/src/styles/index.cssr.js +525 -0
  411. package/lib/header/src/utils.d.ts +12 -0
  412. package/lib/header/src/utils.js +58 -0
  413. package/lib/header/styles/dark.d.ts +36 -0
  414. package/lib/header/styles/dark.js +11 -0
  415. package/lib/header/styles/index.d.ts +3 -0
  416. package/lib/header/styles/index.js +10 -0
  417. package/lib/header/styles/light.d.ts +72 -0
  418. package/lib/header/styles/light.js +49 -0
  419. package/lib/icon/src/Icon.d.ts +3 -0
  420. package/lib/icon/src/Icon.js +3 -2
  421. package/lib/icon-bar/index.d.ts +4 -0
  422. package/lib/icon-bar/index.js +12 -0
  423. package/lib/icon-bar/src/IconBar.d.ts +175 -0
  424. package/lib/icon-bar/src/IconBar.js +63 -0
  425. package/lib/icon-bar/src/IconBarItem.d.ts +163 -0
  426. package/lib/icon-bar/src/IconBarItem.js +56 -0
  427. package/lib/icon-bar/src/styles/index.cssr.d.ts +2 -0
  428. package/lib/icon-bar/src/styles/index.cssr.js +67 -0
  429. package/lib/icon-bar/styles/dark.d.ts +3 -0
  430. package/lib/icon-bar/styles/dark.js +10 -0
  431. package/lib/icon-bar/styles/index.d.ts +3 -0
  432. package/lib/icon-bar/styles/index.js +10 -0
  433. package/lib/icon-bar/styles/light.d.ts +19 -0
  434. package/lib/icon-bar/styles/light.js +27 -0
  435. package/lib/icon-wrapper/src/IconWrapper.d.ts +1 -1
  436. package/lib/input/src/Input.d.ts +8 -8
  437. package/lib/input-number/src/InputNumber.d.ts +3 -3
  438. package/lib/input-otp/src/InputOtp.d.ts +1 -1
  439. package/lib/layout/src/LayoutSider.d.ts +2 -2
  440. package/lib/legacy-grid/src/Row.d.ts +1 -1
  441. package/lib/legacy-transfer/src/Transfer.d.ts +2 -2
  442. package/lib/list/src/List.d.ts +6 -6
  443. package/lib/list/src/ListItem.d.ts +4 -4
  444. package/lib/locales/common/arDZ.js +11 -1
  445. package/lib/locales/common/deDE.js +11 -1
  446. package/lib/locales/common/enGB.js +11 -1
  447. package/lib/locales/common/enUS.d.ts +10 -0
  448. package/lib/locales/common/enUS.js +11 -1
  449. package/lib/locales/common/eo.js +11 -1
  450. package/lib/locales/common/esAR.js +11 -1
  451. package/lib/locales/common/faIR.js +11 -1
  452. package/lib/locales/common/frFR.js +11 -1
  453. package/lib/locales/common/idID.js +11 -1
  454. package/lib/locales/common/itIT.js +11 -1
  455. package/lib/locales/common/jaJP.js +11 -1
  456. package/lib/locales/common/koKR.js +11 -1
  457. package/lib/locales/common/nbNO.js +11 -1
  458. package/lib/locales/common/nlNL.js +11 -1
  459. package/lib/locales/common/plPL.js +11 -1
  460. package/lib/locales/common/ptBR.js +11 -1
  461. package/lib/locales/common/ruRU.js +11 -1
  462. package/lib/locales/common/skSK.js +11 -1
  463. package/lib/locales/common/svSE.js +11 -1
  464. package/lib/locales/common/thTH.js +11 -1
  465. package/lib/locales/common/trTR.js +11 -1
  466. package/lib/locales/common/ukUA.js +11 -1
  467. package/lib/locales/common/viVN.js +11 -1
  468. package/lib/locales/common/zhCN.js +11 -1
  469. package/lib/locales/common/zhTW.js +11 -1
  470. package/lib/log/src/Log.d.ts +2 -2
  471. package/lib/mention/src/Mention.d.ts +3 -3
  472. package/lib/menu/src/Menu.d.ts +5 -5
  473. package/lib/menu/src/MenuOption.d.ts +1 -1
  474. package/lib/menu/src/MenuOptionContent.d.ts +1 -1
  475. package/lib/menu/src/MenuOptionGroup.d.ts +1 -1
  476. package/lib/menu/src/Submenu.d.ts +1 -1
  477. package/lib/message/src/MessageProvider.d.ts +1 -1
  478. package/lib/modal/src/BodyWrapper.d.ts +3 -3
  479. package/lib/modal/src/Modal.d.ts +6 -6
  480. package/lib/modal/src/presetProps.d.ts +1 -1
  481. package/lib/modal-fullscreen/src/ModalFull.d.ts +2 -2
  482. package/lib/notification/src/Notification.d.ts +2 -2
  483. package/lib/notification/src/NotificationEnvironment.d.ts +1 -1
  484. package/lib/notification/src/NotificationProvider.d.ts +9 -9
  485. package/lib/number-animation/src/NumberAnimation.d.ts +2 -2
  486. package/lib/pagination/src/Pagination.d.ts +1 -1
  487. package/lib/popconfirm/src/Popconfirm.d.ts +8 -8
  488. package/lib/popover/src/Popover.d.ts +8 -8
  489. package/lib/popover/src/PopoverBody.d.ts +2 -2
  490. package/lib/popselect/src/Popselect.d.ts +81 -81
  491. package/lib/popselect/src/PopselectPanel.d.ts +4 -4
  492. package/lib/progress/src/Circle.d.ts +1 -1
  493. package/lib/progress/src/MultipleCircle.d.ts +1 -1
  494. package/lib/progress/src/Progress.d.ts +4 -4
  495. package/lib/qr-code/index.d.ts +2 -0
  496. package/lib/qr-code/index.js +9 -0
  497. package/lib/qr-code/src/QrCode.d.ts +171 -0
  498. package/lib/qr-code/src/QrCode.js +235 -0
  499. package/lib/qr-code/src/qrcodegen.d.ts +95 -0
  500. package/lib/qr-code/src/qrcodegen.js +950 -0
  501. package/lib/qr-code/src/styles/index.cssr.d.ts +2 -0
  502. package/lib/qr-code/src/styles/index.cssr.js +13 -0
  503. package/lib/qr-code/styles/dark.d.ts +3 -0
  504. package/lib/qr-code/styles/dark.js +13 -0
  505. package/lib/qr-code/styles/index.d.ts +3 -0
  506. package/lib/qr-code/styles/index.js +10 -0
  507. package/lib/qr-code/styles/light.d.ts +9 -0
  508. package/lib/qr-code/styles/light.js +14 -0
  509. package/lib/radio/src/Radio.d.ts +1 -1
  510. package/lib/rate/src/Rate.d.ts +3 -3
  511. package/lib/result/src/Result.d.ts +1 -1
  512. package/lib/select/src/Select.d.ts +19 -19
  513. package/lib/skeleton/src/Skeleton.d.ts +1 -1
  514. package/lib/slider/src/Slider.d.ts +4 -4
  515. package/lib/space/src/Space.d.ts +1 -1
  516. package/lib/spin/src/Spin.d.ts +2 -2
  517. package/lib/steps/src/Steps.d.ts +1 -1
  518. package/lib/switch/src/Switch.d.ts +1 -1
  519. package/lib/tabs/src/Tab.d.ts +1 -1
  520. package/lib/tabs/src/Tabs.d.ts +4 -4
  521. package/lib/tag/src/Tag.d.ts +2 -2
  522. package/lib/tag/src/TagGroup.d.ts +1 -1
  523. package/lib/theme-editor/src/ThemeEditor.d.ts +1 -0
  524. package/lib/themes/dark.js +7 -1
  525. package/lib/themes/light.js +7 -1
  526. package/lib/time/src/Time.d.ts +1 -1
  527. package/lib/time-picker/src/Panel.d.ts +1 -1
  528. package/lib/time-picker/src/TimePicker.d.ts +5 -5
  529. package/lib/timeline/src/TimelineItem.d.ts +1 -1
  530. package/lib/tooltip/src/Tooltip.d.ts +8 -8
  531. package/lib/transfer/src/Transfer.d.ts +3 -3
  532. package/lib/tree/src/Tree.d.ts +18 -18
  533. package/lib/tree/src/TreeNodeCheckbox.d.ts +1 -1
  534. package/lib/tree-select/src/TreeSelect.d.ts +15 -15
  535. package/lib/typography/index.d.ts +1 -0
  536. package/lib/typography/src/create-header.d.ts +1 -1
  537. package/lib/typography/src/headers.d.ts +6 -6
  538. package/lib/typography/src/text.d.ts +44 -5
  539. package/lib/upload/src/Upload.d.ts +11 -11
  540. package/lib/upload/src/UploadFile.d.ts +1 -1
  541. package/lib/version.d.ts +1 -1
  542. package/lib/version.js +1 -1
  543. package/lib/virtual-list/src/VirtualList.d.ts +2 -2
  544. package/lib/watermark/src/Watermark.d.ts +7 -7
  545. package/package.json +1 -1
  546. package/volar.d.ts +166 -153
  547. package/web-types.json +912 -3
@@ -0,0 +1,950 @@
1
+ /* eslint-disable @typescript-eslint/no-namespace */
2
+ /*
3
+ * QR Code generator library (TypeScript)
4
+ *
5
+ * Copyright (c) Project Nayuki. (MIT License)
6
+ * https://www.nayuki.io/page/qr-code-generator-library
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
9
+ * this software and associated documentation files (the "Software"), to deal in
10
+ * the Software without restriction, including without limitation the rights to
11
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
12
+ * the Software, and to permit persons to whom the Software is furnished to do so,
13
+ * subject to the following conditions:
14
+ * - The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ * - The Software is provided "as is", without warranty of any kind, express or
17
+ * implied, including but not limited to the warranties of merchantability,
18
+ * fitness for a particular purpose and noninfringement. In no event shall the
19
+ * authors or copyright holders be liable for any claim, damages or other
20
+ * liability, whether in an action of contract, tort or otherwise, arising from,
21
+ * out of or in connection with the Software or the use or other dealings in the
22
+ * Software.
23
+ */
24
+ 'use strict';
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ var qrcodegen;
27
+ (function (qrcodegen) {
28
+ /* ---- QR Code symbol class ---- */
29
+ /*
30
+ * A QR Code symbol, which is a type of two-dimension barcode.
31
+ * Invented by Denso Wave and described in the ISO/IEC 18004 standard.
32
+ * Instances of this class represent an immutable square grid of dark and light cells.
33
+ * The class provides static factory functions to create a QR Code from text or binary data.
34
+ * The class covers the QR Code Model 2 specification, supporting all versions (sizes)
35
+ * from 1 to 40, all 4 error correction levels, and 4 character encoding modes.
36
+ *
37
+ * Ways to create a QR Code object:
38
+ * - High level: Take the payload data and call QrCode.encodeText() or QrCode.encodeBinary().
39
+ * - Mid level: Custom-make the list of segments and call QrCode.encodeSegments().
40
+ * - Low level: Custom-make the array of data codeword bytes (including
41
+ * segment headers and final padding, excluding error correction codewords),
42
+ * supply the appropriate version number, and call the QrCode() constructor.
43
+ * (Note that all ways require supplying the desired error correction level.)
44
+ */
45
+ class QrCode {
46
+ /* -- Static factory functions (high level) -- */
47
+ // Returns a QR Code representing the given Unicode text string at the given error correction level.
48
+ // As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer
49
+ // Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible
50
+ // QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the
51
+ // ecl argument if it can be done without increasing the version.
52
+ static encodeText(text, ecl) {
53
+ const segs = qrcodegen.QrSegment.makeSegments(text);
54
+ return QrCode.encodeSegments(segs, ecl);
55
+ }
56
+ // Returns a QR Code representing the given binary data at the given error correction level.
57
+ // This function always encodes using the binary segment mode, not any text mode. The maximum number of
58
+ // bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
59
+ // The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.
60
+ static encodeBinary(data, ecl) {
61
+ const seg = qrcodegen.QrSegment.makeBytes(data);
62
+ return QrCode.encodeSegments([seg], ecl);
63
+ }
64
+ /* -- Static factory functions (mid level) -- */
65
+ // Returns a QR Code representing the given segments with the given encoding parameters.
66
+ // The smallest possible QR Code version within the given range is automatically
67
+ // chosen for the output. Iff boostEcl is true, then the ECC level of the result
68
+ // may be higher than the ecl argument if it can be done without increasing the
69
+ // version. The mask number is either between 0 to 7 (inclusive) to force that
70
+ // mask, or -1 to automatically choose an appropriate mask (which may be slow).
71
+ // This function allows the user to create a custom sequence of segments that switches
72
+ // between modes (such as alphanumeric and byte) to encode text in less space.
73
+ // This is a mid-level API; the high-level API is encodeText() and encodeBinary().
74
+ static encodeSegments(segs, ecl, minVersion = 1, maxVersion = 40, mask = -1, boostEcl = true) {
75
+ if (!(QrCode.MIN_VERSION <= minVersion &&
76
+ minVersion <= maxVersion &&
77
+ maxVersion <= QrCode.MAX_VERSION) ||
78
+ mask < -1 ||
79
+ mask > 7) {
80
+ throw new RangeError('Invalid value');
81
+ }
82
+ // Find the minimal version number to use
83
+ let version;
84
+ let dataUsedBits;
85
+ for (version = minVersion;; version++) {
86
+ const dataCapacityBits = QrCode.getNumDataCodewords(version, ecl) * 8; // Number of data bits available
87
+ const usedBits = QrSegment.getTotalBits(segs, version);
88
+ if (usedBits <= dataCapacityBits) {
89
+ dataUsedBits = usedBits;
90
+ break; // This version number is found to be suitable
91
+ }
92
+ if (version >= maxVersion) {
93
+ // All versions in the range could not fit the given data
94
+ throw new RangeError('Data too long');
95
+ }
96
+ }
97
+ // Increase the error correction level while the data still fits in the current version number
98
+ for (const newEcl of [
99
+ QrCode.Ecc.MEDIUM,
100
+ QrCode.Ecc.QUARTILE,
101
+ QrCode.Ecc.HIGH
102
+ ]) {
103
+ // From low to high
104
+ if (boostEcl &&
105
+ dataUsedBits <= QrCode.getNumDataCodewords(version, newEcl) * 8) {
106
+ ecl = newEcl;
107
+ }
108
+ }
109
+ // Concatenate all segments to create the data bit string
110
+ const bb = [];
111
+ for (const seg of segs) {
112
+ appendBits(seg.mode.modeBits, 4, bb);
113
+ appendBits(seg.numChars, seg.mode.numCharCountBits(version), bb);
114
+ for (const b of seg.getData()) {
115
+ bb.push(b);
116
+ }
117
+ }
118
+ // Add terminator and pad up to a byte if applicable
119
+ const dataCapacityBits = QrCode.getNumDataCodewords(version, ecl) * 8;
120
+ appendBits(0, Math.min(4, dataCapacityBits - bb.length), bb);
121
+ appendBits(0, (8 - (bb.length % 8)) % 8, bb);
122
+ // Pad with alternating bytes until data capacity is reached
123
+ for (let padByte = 0xec; bb.length < dataCapacityBits; padByte ^= 0xec ^ 0x11) {
124
+ appendBits(padByte, 8, bb);
125
+ }
126
+ // Pack bits into bytes in big endian
127
+ const dataCodewords = [];
128
+ while (dataCodewords.length * 8 < bb.length) {
129
+ dataCodewords.push(0);
130
+ }
131
+ bb.forEach((b, i) => (dataCodewords[i >>> 3] |= b << (7 - (i & 7))));
132
+ // Create the QR Code object
133
+ return new QrCode(version, ecl, dataCodewords, mask);
134
+ }
135
+ /* -- Constructor (low level) and fields -- */
136
+ // Creates a new QR Code with the given version number,
137
+ // error correction level, data codeword bytes, and mask number.
138
+ // This is a low-level API that most users should not use directly.
139
+ // A mid-level API is the encodeSegments() function.
140
+ constructor(
141
+ // The version number of this QR Code, which is between 1 and 40 (inclusive).
142
+ // This determines the size of this barcode.
143
+ version,
144
+ // The error correction level used in this QR Code.
145
+ errorCorrectionLevel, dataCodewords, msk) {
146
+ this.version = version;
147
+ this.errorCorrectionLevel = errorCorrectionLevel;
148
+ // The modules of this QR Code (false = light, true = dark).
149
+ // Immutable after constructor finishes. Accessed through getModule().
150
+ this.modules = [];
151
+ // Indicates function modules that are not subjected to masking. Discarded when constructor finishes.
152
+ this.isFunction = [];
153
+ // Check scalar arguments
154
+ if (version < QrCode.MIN_VERSION || version > QrCode.MAX_VERSION) {
155
+ throw new RangeError('Version value out of range');
156
+ }
157
+ if (msk < -1 || msk > 7) {
158
+ throw new RangeError('Mask value out of range');
159
+ }
160
+ this.size = version * 4 + 17;
161
+ // Initialize both grids to be size*size arrays of Boolean false
162
+ const row = [];
163
+ for (let i = 0; i < this.size; i++) {
164
+ row.push(false);
165
+ }
166
+ for (let i = 0; i < this.size; i++) {
167
+ this.modules.push(row.slice()); // Initially all light
168
+ this.isFunction.push(row.slice());
169
+ }
170
+ // Compute ECC, draw modules
171
+ this.drawFunctionPatterns();
172
+ const allCodewords = this.addEccAndInterleave(dataCodewords);
173
+ this.drawCodewords(allCodewords);
174
+ // Do masking
175
+ if (msk === -1) {
176
+ // Automatically choose best mask
177
+ let minPenalty = 1000000000;
178
+ for (let i = 0; i < 8; i++) {
179
+ this.applyMask(i);
180
+ this.drawFormatBits(i);
181
+ const penalty = this.getPenaltyScore();
182
+ if (penalty < minPenalty) {
183
+ msk = i;
184
+ minPenalty = penalty;
185
+ }
186
+ this.applyMask(i); // Undoes the mask due to XOR
187
+ }
188
+ }
189
+ this.mask = msk;
190
+ this.applyMask(msk); // Apply the final choice of mask
191
+ this.drawFormatBits(msk); // Overwrite old format bits
192
+ this.isFunction = [];
193
+ }
194
+ /* -- Accessor methods -- */
195
+ // Returns the color of the module (pixel) at the given coordinates, which is false
196
+ // for light or true for dark. The top left corner has the coordinates (x=0, y=0).
197
+ // If the given coordinates are out of bounds, then false (light) is returned.
198
+ getModule(x, y) {
199
+ return (x >= 0 && x < this.size && y >= 0 && y < this.size && this.modules[y][x]);
200
+ }
201
+ // Modified to expose modules for easy access
202
+ getModules() {
203
+ return this.modules;
204
+ }
205
+ /* -- Private helper methods for constructor: Drawing function modules -- */
206
+ // Reads this object's version field, and draws and marks all function modules.
207
+ drawFunctionPatterns() {
208
+ // Draw horizontal and vertical timing patterns
209
+ for (let i = 0; i < this.size; i++) {
210
+ this.setFunctionModule(6, i, i % 2 === 0);
211
+ this.setFunctionModule(i, 6, i % 2 === 0);
212
+ }
213
+ // Draw 3 finder patterns (all corners except bottom right; overwrites some timing modules)
214
+ this.drawFinderPattern(3, 3);
215
+ this.drawFinderPattern(this.size - 4, 3);
216
+ this.drawFinderPattern(3, this.size - 4);
217
+ // Draw numerous alignment patterns
218
+ const alignPatPos = this.getAlignmentPatternPositions();
219
+ const numAlign = alignPatPos.length;
220
+ for (let i = 0; i < numAlign; i++) {
221
+ for (let j = 0; j < numAlign; j++) {
222
+ // Don't draw on the three finder corners
223
+ if (!((i === 0 && j === 0) ||
224
+ (i === 0 && j === numAlign - 1) ||
225
+ (i === numAlign - 1 && j === 0))) {
226
+ this.drawAlignmentPattern(alignPatPos[i], alignPatPos[j]);
227
+ }
228
+ }
229
+ }
230
+ // Draw configuration data
231
+ this.drawFormatBits(0); // Dummy mask value; overwritten later in the constructor
232
+ this.drawVersion();
233
+ }
234
+ // Draws two copies of the format bits (with its own error correction code)
235
+ // based on the given mask and this object's error correction level field.
236
+ drawFormatBits(mask) {
237
+ // Calculate error correction code and pack bits
238
+ const data = (this.errorCorrectionLevel.formatBits << 3) | mask; // errCorrLvl is uint2, mask is uint3
239
+ let rem = data;
240
+ for (let i = 0; i < 10; i++) {
241
+ rem = (rem << 1) ^ ((rem >>> 9) * 0x537);
242
+ }
243
+ const bits = ((data << 10) | rem) ^ 0x5412; // uint15
244
+ // Draw first copy
245
+ for (let i = 0; i <= 5; i++) {
246
+ this.setFunctionModule(8, i, getBit(bits, i));
247
+ }
248
+ this.setFunctionModule(8, 7, getBit(bits, 6));
249
+ this.setFunctionModule(8, 8, getBit(bits, 7));
250
+ this.setFunctionModule(7, 8, getBit(bits, 8));
251
+ for (let i = 9; i < 15; i++) {
252
+ this.setFunctionModule(14 - i, 8, getBit(bits, i));
253
+ }
254
+ // Draw second copy
255
+ for (let i = 0; i < 8; i++) {
256
+ this.setFunctionModule(this.size - 1 - i, 8, getBit(bits, i));
257
+ }
258
+ for (let i = 8; i < 15; i++) {
259
+ this.setFunctionModule(8, this.size - 15 + i, getBit(bits, i));
260
+ }
261
+ this.setFunctionModule(8, this.size - 8, true); // Always dark
262
+ }
263
+ // Draws two copies of the version bits (with its own error correction code),
264
+ // based on this object's version field, iff 7 <= version <= 40.
265
+ drawVersion() {
266
+ if (this.version < 7) {
267
+ return;
268
+ }
269
+ // Calculate error correction code and pack bits
270
+ let rem = this.version; // version is uint6, in the range [7, 40]
271
+ for (let i = 0; i < 12; i++) {
272
+ rem = (rem << 1) ^ ((rem >>> 11) * 0x1f25);
273
+ }
274
+ const bits = (this.version << 12) | rem; // uint18
275
+ // Draw two copies
276
+ for (let i = 0; i < 18; i++) {
277
+ const color = getBit(bits, i);
278
+ const a = this.size - 11 + (i % 3);
279
+ const b = Math.floor(i / 3);
280
+ this.setFunctionModule(a, b, color);
281
+ this.setFunctionModule(b, a, color);
282
+ }
283
+ }
284
+ // Draws a 9*9 finder pattern including the border separator,
285
+ // with the center module at (x, y). Modules can be out of bounds.
286
+ drawFinderPattern(x, y) {
287
+ for (let dy = -4; dy <= 4; dy++) {
288
+ for (let dx = -4; dx <= 4; dx++) {
289
+ const dist = Math.max(Math.abs(dx), Math.abs(dy)); // Chebyshev/infinity norm
290
+ const xx = x + dx;
291
+ const yy = y + dy;
292
+ if (xx >= 0 && xx < this.size && yy >= 0 && yy < this.size) {
293
+ this.setFunctionModule(xx, yy, dist !== 2 && dist !== 4);
294
+ }
295
+ }
296
+ }
297
+ }
298
+ // Draws a 5*5 alignment pattern, with the center module
299
+ // at (x, y). All modules must be in bounds.
300
+ drawAlignmentPattern(x, y) {
301
+ for (let dy = -2; dy <= 2; dy++) {
302
+ for (let dx = -2; dx <= 2; dx++) {
303
+ this.setFunctionModule(x + dx, y + dy, Math.max(Math.abs(dx), Math.abs(dy)) !== 1);
304
+ }
305
+ }
306
+ }
307
+ // Sets the color of a module and marks it as a function module.
308
+ // Only used by the constructor. Coordinates must be in bounds.
309
+ setFunctionModule(x, y, isDark) {
310
+ this.modules[y][x] = isDark;
311
+ this.isFunction[y][x] = true;
312
+ }
313
+ /* -- Private helper methods for constructor: Codewords and masking -- */
314
+ // Returns a new byte string representing the given data with the appropriate error correction
315
+ // codewords appended to it, based on this object's version and error correction level.
316
+ addEccAndInterleave(data) {
317
+ const ver = this.version;
318
+ const ecl = this.errorCorrectionLevel;
319
+ if (data.length !== QrCode.getNumDataCodewords(ver, ecl)) {
320
+ throw new RangeError('Invalid argument');
321
+ }
322
+ // Calculate parameter numbers
323
+ const numBlocks = QrCode.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];
324
+ const blockEccLen = QrCode.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver];
325
+ const rawCodewords = Math.floor(QrCode.getNumRawDataModules(ver) / 8);
326
+ const numShortBlocks = numBlocks - (rawCodewords % numBlocks);
327
+ const shortBlockLen = Math.floor(rawCodewords / numBlocks);
328
+ // Split data into blocks and append ECC to each block
329
+ const blocks = [];
330
+ const rsDiv = QrCode.reedSolomonComputeDivisor(blockEccLen);
331
+ for (let i = 0, k = 0; i < numBlocks; i++) {
332
+ const dat = data.slice(k, k + shortBlockLen - blockEccLen + (i < numShortBlocks ? 0 : 1));
333
+ k += dat.length;
334
+ const ecc = QrCode.reedSolomonComputeRemainder(dat, rsDiv);
335
+ if (i < numShortBlocks) {
336
+ dat.push(0);
337
+ }
338
+ blocks.push(dat.concat(ecc));
339
+ }
340
+ // Interleave (not concatenate) the bytes from every block into a single sequence
341
+ const result = [];
342
+ for (let i = 0; i < blocks[0].length; i++) {
343
+ blocks.forEach((block, j) => {
344
+ // Skip the padding byte in short blocks
345
+ if (i !== shortBlockLen - blockEccLen || j >= numShortBlocks) {
346
+ result.push(block[i]);
347
+ }
348
+ });
349
+ }
350
+ return result;
351
+ }
352
+ // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
353
+ // data area of this QR Code. Function modules need to be marked off before this is called.
354
+ drawCodewords(data) {
355
+ if (data.length !==
356
+ Math.floor(QrCode.getNumRawDataModules(this.version) / 8)) {
357
+ throw new RangeError('Invalid argument');
358
+ }
359
+ let i = 0; // Bit index into the data
360
+ // Do the funny zigzag scan
361
+ for (let right = this.size - 1; right >= 1; right -= 2) {
362
+ // Index of right column in each column pair
363
+ if (right === 6) {
364
+ right = 5;
365
+ }
366
+ for (let vert = 0; vert < this.size; vert++) {
367
+ // Vertical counter
368
+ for (let j = 0; j < 2; j++) {
369
+ const x = right - j; // Actual x coordinate
370
+ const upward = ((right + 1) & 2) === 0;
371
+ const y = upward ? this.size - 1 - vert : vert; // Actual y coordinate
372
+ if (!this.isFunction[y][x] && i < data.length * 8) {
373
+ this.modules[y][x] = getBit(data[i >>> 3], 7 - (i & 7));
374
+ i++;
375
+ }
376
+ // If this QR Code has any remainder bits (0 to 7), they were assigned as
377
+ // 0/false/light by the constructor and are left unchanged by this method
378
+ }
379
+ }
380
+ }
381
+ }
382
+ // XORs the codeword modules in this QR Code with the given mask pattern.
383
+ // The function modules must be marked and the codeword bits must be drawn
384
+ // before masking. Due to the arithmetic of XOR, calling applyMask() with
385
+ // the same mask value a second time will undo the mask. A final well-formed
386
+ // QR Code needs exactly one (not zero, two, etc.) mask applied.
387
+ applyMask(mask) {
388
+ if (mask < 0 || mask > 7) {
389
+ throw new RangeError('Mask value out of range');
390
+ }
391
+ for (let y = 0; y < this.size; y++) {
392
+ for (let x = 0; x < this.size; x++) {
393
+ let invert;
394
+ switch (mask) {
395
+ case 0:
396
+ invert = (x + y) % 2 === 0;
397
+ break;
398
+ case 1:
399
+ invert = y % 2 === 0;
400
+ break;
401
+ case 2:
402
+ invert = x % 3 === 0;
403
+ break;
404
+ case 3:
405
+ invert = (x + y) % 3 === 0;
406
+ break;
407
+ case 4:
408
+ invert = (Math.floor(x / 3) + Math.floor(y / 2)) % 2 === 0;
409
+ break;
410
+ case 5:
411
+ invert = ((x * y) % 2) + ((x * y) % 3) === 0;
412
+ break;
413
+ case 6:
414
+ invert = (((x * y) % 2) + ((x * y) % 3)) % 2 === 0;
415
+ break;
416
+ case 7:
417
+ invert = (((x + y) % 2) + ((x * y) % 3)) % 2 === 0;
418
+ break;
419
+ default:
420
+ throw new Error('Unreachable');
421
+ }
422
+ if (!this.isFunction[y][x] && invert) {
423
+ this.modules[y][x] = !this.modules[y][x];
424
+ }
425
+ }
426
+ }
427
+ }
428
+ // Calculates and returns the penalty score based on state of this QR Code's current modules.
429
+ // This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.
430
+ getPenaltyScore() {
431
+ let result = 0;
432
+ // Adjacent modules in row having same color, and finder-like patterns
433
+ for (let y = 0; y < this.size; y++) {
434
+ let runColor = false;
435
+ let runX = 0;
436
+ const runHistory = [0, 0, 0, 0, 0, 0, 0];
437
+ for (let x = 0; x < this.size; x++) {
438
+ if (this.modules[y][x] === runColor) {
439
+ runX++;
440
+ if (runX === 5) {
441
+ result += QrCode.PENALTY_N1;
442
+ }
443
+ else if (runX > 5) {
444
+ result++;
445
+ }
446
+ }
447
+ else {
448
+ this.finderPenaltyAddHistory(runX, runHistory);
449
+ if (!runColor) {
450
+ result +=
451
+ this.finderPenaltyCountPatterns(runHistory) * QrCode.PENALTY_N3;
452
+ }
453
+ runColor = this.modules[y][x];
454
+ runX = 1;
455
+ }
456
+ }
457
+ result +=
458
+ this.finderPenaltyTerminateAndCount(runColor, runX, runHistory) *
459
+ QrCode.PENALTY_N3;
460
+ }
461
+ // Adjacent modules in column having same color, and finder-like patterns
462
+ for (let x = 0; x < this.size; x++) {
463
+ let runColor = false;
464
+ let runY = 0;
465
+ const runHistory = [0, 0, 0, 0, 0, 0, 0];
466
+ for (let y = 0; y < this.size; y++) {
467
+ if (this.modules[y][x] === runColor) {
468
+ runY++;
469
+ if (runY === 5) {
470
+ result += QrCode.PENALTY_N1;
471
+ }
472
+ else if (runY > 5) {
473
+ result++;
474
+ }
475
+ }
476
+ else {
477
+ this.finderPenaltyAddHistory(runY, runHistory);
478
+ if (!runColor) {
479
+ result +=
480
+ this.finderPenaltyCountPatterns(runHistory) * QrCode.PENALTY_N3;
481
+ }
482
+ runColor = this.modules[y][x];
483
+ runY = 1;
484
+ }
485
+ }
486
+ result +=
487
+ this.finderPenaltyTerminateAndCount(runColor, runY, runHistory) *
488
+ QrCode.PENALTY_N3;
489
+ }
490
+ // 2*2 blocks of modules having same color
491
+ for (let y = 0; y < this.size - 1; y++) {
492
+ for (let x = 0; x < this.size - 1; x++) {
493
+ const color = this.modules[y][x];
494
+ if (color === this.modules[y][x + 1] &&
495
+ color === this.modules[y + 1][x] &&
496
+ color === this.modules[y + 1][x + 1]) {
497
+ result += QrCode.PENALTY_N2;
498
+ }
499
+ }
500
+ }
501
+ // Balance of dark and light modules
502
+ let dark = 0;
503
+ for (const row of this.modules) {
504
+ dark = row.reduce((sum, color) => sum + (color ? 1 : 0), dark);
505
+ }
506
+ const total = this.size * this.size; // Note that size is odd, so dark/total != 1/2
507
+ // Compute the smallest integer k >= 0 such that (45-5k)% <= dark/total <= (55+5k)%
508
+ const k = Math.ceil(Math.abs(dark * 20 - total * 10) / total) - 1;
509
+ result += k * QrCode.PENALTY_N4;
510
+ return result;
511
+ }
512
+ /* -- Private helper functions -- */
513
+ // Returns an ascending list of positions of alignment patterns for this version number.
514
+ // Each position is in the range [0,177), and are used on both the x and y axes.
515
+ // This could be implemented as lookup table of 40 variable-length lists of integers.
516
+ getAlignmentPatternPositions() {
517
+ if (this.version === 1) {
518
+ return [];
519
+ }
520
+ else {
521
+ const numAlign = Math.floor(this.version / 7) + 2;
522
+ const step = this.version === 32
523
+ ? 26
524
+ : Math.ceil((this.version * 4 + 4) / (numAlign * 2 - 2)) * 2;
525
+ const result = [6];
526
+ for (let pos = this.size - 7; result.length < numAlign; pos -= step) {
527
+ result.splice(1, 0, pos);
528
+ }
529
+ return result;
530
+ }
531
+ }
532
+ // Returns the number of data bits that can be stored in a QR Code of the given version number, after
533
+ // all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.
534
+ // The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.
535
+ static getNumRawDataModules(ver) {
536
+ if (ver < QrCode.MIN_VERSION || ver > QrCode.MAX_VERSION) {
537
+ throw new RangeError('Version number out of range');
538
+ }
539
+ let result = (16 * ver + 128) * ver + 64;
540
+ if (ver >= 2) {
541
+ const numAlign = Math.floor(ver / 7) + 2;
542
+ result -= (25 * numAlign - 10) * numAlign - 55;
543
+ if (ver >= 7) {
544
+ result -= 36;
545
+ }
546
+ }
547
+ return result;
548
+ }
549
+ // Returns the number of 8-bit data (i.e. not error correction) codewords contained in any
550
+ // QR Code of the given version number and error correction level, with remainder bits discarded.
551
+ // This stateless pure function could be implemented as a (40*4)-cell lookup table.
552
+ static getNumDataCodewords(ver, ecl) {
553
+ return (Math.floor(QrCode.getNumRawDataModules(ver) / 8) -
554
+ QrCode.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver] *
555
+ QrCode.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver]);
556
+ }
557
+ // Returns a Reed-Solomon ECC generator polynomial for the given degree. This could be
558
+ // implemented as a lookup table over all possible parameter values, instead of as an algorithm.
559
+ static reedSolomonComputeDivisor(degree) {
560
+ if (degree < 1 || degree > 255) {
561
+ throw new RangeError('Degree out of range');
562
+ }
563
+ // Polynomial coefficients are stored from highest to lowest power, excluding the leading term which is always 1.
564
+ // For example the polynomial x^3 + 255x^2 + 8x + 93 is stored as the uint8 array [255, 8, 93].
565
+ const result = [];
566
+ for (let i = 0; i < degree - 1; i++) {
567
+ result.push(0);
568
+ }
569
+ result.push(1); // Start off with the monomial x^0
570
+ // Compute the product polynomial (x - r^0) * (x - r^1) * (x - r^2) * ... * (x - r^{degree-1}),
571
+ // and drop the highest monomial term which is always 1x^degree.
572
+ // Note that r = 0x02, which is a generator element of this field GF(2^8/0x11D).
573
+ let root = 1;
574
+ for (let i = 0; i < degree; i++) {
575
+ // Multiply the current product by (x - r^i)
576
+ for (let j = 0; j < result.length; j++) {
577
+ result[j] = QrCode.reedSolomonMultiply(result[j], root);
578
+ if (j + 1 < result.length) {
579
+ result[j] ^= result[j + 1];
580
+ }
581
+ }
582
+ root = QrCode.reedSolomonMultiply(root, 0x02);
583
+ }
584
+ return result;
585
+ }
586
+ // Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials.
587
+ static reedSolomonComputeRemainder(data, divisor) {
588
+ const result = divisor.map((_) => 0);
589
+ for (const b of data) {
590
+ // Polynomial division
591
+ const factor = b ^ result.shift();
592
+ result.push(0);
593
+ divisor.forEach((coef, i) => (result[i] ^= QrCode.reedSolomonMultiply(coef, factor)));
594
+ }
595
+ return result;
596
+ }
597
+ // Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result
598
+ // are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8.
599
+ static reedSolomonMultiply(x, y) {
600
+ if (x >>> 8 !== 0 || y >>> 8 !== 0) {
601
+ throw new RangeError('Byte out of range');
602
+ }
603
+ // Russian peasant multiplication
604
+ let z = 0;
605
+ for (let i = 7; i >= 0; i--) {
606
+ z = (z << 1) ^ ((z >>> 7) * 0x11d);
607
+ z ^= ((y >>> i) & 1) * x;
608
+ }
609
+ return z;
610
+ }
611
+ // Can only be called immediately after a light run is added, and
612
+ // returns either 0, 1, or 2. A helper function for getPenaltyScore().
613
+ finderPenaltyCountPatterns(runHistory) {
614
+ const n = runHistory[1];
615
+ const core = n > 0 &&
616
+ runHistory[2] === n &&
617
+ runHistory[3] === n * 3 &&
618
+ runHistory[4] === n &&
619
+ runHistory[5] === n;
620
+ return ((core && runHistory[0] >= n * 4 && runHistory[6] >= n ? 1 : 0) +
621
+ (core && runHistory[6] >= n * 4 && runHistory[0] >= n ? 1 : 0));
622
+ }
623
+ // Must be called at the end of a line (row or column) of modules. A helper function for getPenaltyScore().
624
+ finderPenaltyTerminateAndCount(currentRunColor, currentRunLength, runHistory) {
625
+ if (currentRunColor) {
626
+ // Terminate dark run
627
+ this.finderPenaltyAddHistory(currentRunLength, runHistory);
628
+ currentRunLength = 0;
629
+ }
630
+ currentRunLength += this.size; // Add light border to final run
631
+ this.finderPenaltyAddHistory(currentRunLength, runHistory);
632
+ return this.finderPenaltyCountPatterns(runHistory);
633
+ }
634
+ // Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore().
635
+ finderPenaltyAddHistory(currentRunLength, runHistory) {
636
+ if (runHistory[0] === 0) {
637
+ currentRunLength += this.size;
638
+ } // Add light border to initial run
639
+ runHistory.pop();
640
+ runHistory.unshift(currentRunLength);
641
+ }
642
+ }
643
+ /* -- Constants and tables -- */
644
+ // The minimum version number supported in the QR Code Model 2 standard.
645
+ QrCode.MIN_VERSION = 1;
646
+ // The maximum version number supported in the QR Code Model 2 standard.
647
+ QrCode.MAX_VERSION = 40;
648
+ // For use in getPenaltyScore(), when evaluating which mask is best.
649
+ QrCode.PENALTY_N1 = 3;
650
+ QrCode.PENALTY_N2 = 3;
651
+ QrCode.PENALTY_N3 = 40;
652
+ QrCode.PENALTY_N4 = 10;
653
+ QrCode.ECC_CODEWORDS_PER_BLOCK = [
654
+ // Version: (note that index 0 is for padding, and is set to an illegal value)
655
+ // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
656
+ [
657
+ -1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28,
658
+ 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30,
659
+ 30, 30, 30, 30, 30
660
+ ], // Low
661
+ [
662
+ -1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28,
663
+ 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
664
+ 28, 28, 28, 28, 28
665
+ ], // Medium
666
+ [
667
+ -1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28,
668
+ 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30,
669
+ 30, 30, 30, 30, 30
670
+ ], // Quartile
671
+ [
672
+ -1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28,
673
+ 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
674
+ 30, 30, 30, 30, 30
675
+ ] // High
676
+ ];
677
+ QrCode.NUM_ERROR_CORRECTION_BLOCKS = [
678
+ // Version: (note that index 0 is for padding, and is set to an illegal value)
679
+ // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
680
+ [
681
+ -1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9,
682
+ 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25
683
+ ], // Low
684
+ [
685
+ -1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16,
686
+ 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45,
687
+ 47, 49
688
+ ], // Medium
689
+ [
690
+ -1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20,
691
+ 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62,
692
+ 65, 68
693
+ ], // Quartile
694
+ [
695
+ -1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25,
696
+ 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70,
697
+ 74, 77, 81
698
+ ] // High
699
+ ];
700
+ qrcodegen.QrCode = QrCode;
701
+ // Appends the given number of low-order bits of the given value
702
+ // to the given buffer. Requires 0 <= len <= 31 and 0 <= val < 2^len.
703
+ function appendBits(val, len, bb) {
704
+ if (len < 0 || len > 31 || val >>> len !== 0) {
705
+ throw new RangeError('Value out of range');
706
+ }
707
+ for (let i = len - 1; i >= 0; i-- // Append bit by bit
708
+ ) {
709
+ bb.push((val >>> i) & 1);
710
+ }
711
+ }
712
+ // Returns true iff the i'th bit of x is set to 1.
713
+ function getBit(x, i) {
714
+ return ((x >>> i) & 1) !== 0;
715
+ }
716
+ /* ---- Data segment class ---- */
717
+ /*
718
+ * A segment of character/binary/control data in a QR Code symbol.
719
+ * Instances of this class are immutable.
720
+ * The mid-level way to create a segment is to take the payload data
721
+ * and call a static factory function such as QrSegment.makeNumeric().
722
+ * The low-level way to create a segment is to custom-make the bit buffer
723
+ * and call the QrSegment() constructor with appropriate values.
724
+ * This segment class imposes no length restrictions, but QR Codes have restrictions.
725
+ * Even in the most favorable conditions, a QR Code can only hold 7089 characters of data.
726
+ * Any segment longer than this is meaningless for the purpose of generating QR Codes.
727
+ */
728
+ class QrSegment {
729
+ /* -- Static factory functions (mid level) -- */
730
+ // Returns a segment representing the given binary data encoded in
731
+ // byte mode. All input byte arrays are acceptable. Any text string
732
+ // can be converted to UTF-8 bytes and encoded as a byte mode segment.
733
+ static makeBytes(data) {
734
+ const bb = [];
735
+ for (const b of data) {
736
+ appendBits(b, 8, bb);
737
+ }
738
+ return new QrSegment(QrSegment.Mode.BYTE, data.length, bb);
739
+ }
740
+ // Returns a segment representing the given string of decimal digits encoded in numeric mode.
741
+ static makeNumeric(digits) {
742
+ if (!QrSegment.isNumeric(digits)) {
743
+ throw new RangeError('String contains non-numeric characters');
744
+ }
745
+ const bb = [];
746
+ for (let i = 0; i < digits.length;) {
747
+ // Consume up to 3 digits per iteration
748
+ const n = Math.min(digits.length - i, 3);
749
+ appendBits(Number.parseInt(digits.substr(i, n), 10), n * 3 + 1, bb);
750
+ i += n;
751
+ }
752
+ return new QrSegment(QrSegment.Mode.NUMERIC, digits.length, bb);
753
+ }
754
+ // Returns a segment representing the given text string encoded in alphanumeric mode.
755
+ // The characters allowed are: 0 to 9, A to Z (uppercase only), space,
756
+ // dollar, percent, asterisk, plus, hyphen, period, slash, colon.
757
+ static makeAlphanumeric(text) {
758
+ if (!QrSegment.isAlphanumeric(text)) {
759
+ throw new RangeError('String contains unencodable characters in alphanumeric mode');
760
+ }
761
+ const bb = [];
762
+ let i;
763
+ for (i = 0; i + 2 <= text.length; i += 2) {
764
+ // Process groups of 2
765
+ let temp = QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)) * 45;
766
+ temp += QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i + 1));
767
+ appendBits(temp, 11, bb);
768
+ }
769
+ if (i < text.length) {
770
+ // 1 character remaining
771
+ appendBits(QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)), 6, bb);
772
+ }
773
+ return new QrSegment(QrSegment.Mode.ALPHANUMERIC, text.length, bb);
774
+ }
775
+ // Returns a new mutable list of zero or more segments to represent the given Unicode text string.
776
+ // The result may use various segment modes and switch modes to optimize the length of the bit stream.
777
+ static makeSegments(text) {
778
+ // Select the most efficient segment encoding automatically
779
+ if (text === '') {
780
+ return [];
781
+ }
782
+ else if (QrSegment.isNumeric(text)) {
783
+ return [QrSegment.makeNumeric(text)];
784
+ }
785
+ else if (QrSegment.isAlphanumeric(text)) {
786
+ return [QrSegment.makeAlphanumeric(text)];
787
+ }
788
+ else {
789
+ return [QrSegment.makeBytes(QrSegment.toUtf8ByteArray(text))];
790
+ }
791
+ }
792
+ // Returns a segment representing an Extended Channel Interpretation
793
+ // (ECI) designator with the given assignment value.
794
+ static makeEci(assignVal) {
795
+ const bb = [];
796
+ if (assignVal < 0) {
797
+ throw new RangeError('ECI assignment value out of range');
798
+ }
799
+ else if (assignVal < 1 << 7) {
800
+ appendBits(assignVal, 8, bb);
801
+ }
802
+ else if (assignVal < 1 << 14) {
803
+ appendBits(0b10, 2, bb);
804
+ appendBits(assignVal, 14, bb);
805
+ }
806
+ else if (assignVal < 1000000) {
807
+ appendBits(0b110, 3, bb);
808
+ appendBits(assignVal, 21, bb);
809
+ }
810
+ else {
811
+ throw new RangeError('ECI assignment value out of range');
812
+ }
813
+ return new QrSegment(QrSegment.Mode.ECI, 0, bb);
814
+ }
815
+ // Tests whether the given string can be encoded as a segment in numeric mode.
816
+ // A string is encodable iff each character is in the range 0 to 9.
817
+ static isNumeric(text) {
818
+ return QrSegment.NUMERIC_REGEX.test(text);
819
+ }
820
+ // Tests whether the given string can be encoded as a segment in alphanumeric mode.
821
+ // A string is encodable iff each character is in the following set: 0 to 9, A to Z
822
+ // (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.
823
+ static isAlphanumeric(text) {
824
+ return QrSegment.ALPHANUMERIC_REGEX.test(text);
825
+ }
826
+ /* -- Constructor (low level) and fields -- */
827
+ // Creates a new QR Code segment with the given attributes and data.
828
+ // The character count (numChars) must agree with the mode and the bit buffer length,
829
+ // but the constraint isn't checked. The given bit buffer is cloned and stored.
830
+ constructor(
831
+ // The mode indicator of this segment.
832
+ mode,
833
+ // The length of this segment's unencoded data. Measured in characters for
834
+ // numeric/alphanumeric/kanji mode, bytes for byte mode, and 0 for ECI mode.
835
+ // Always zero or positive. Not the same as the data's bit length.
836
+ numChars,
837
+ // The data bits of this segment. Accessed through getData().
838
+ bitData) {
839
+ this.mode = mode;
840
+ this.numChars = numChars;
841
+ this.bitData = bitData;
842
+ if (numChars < 0) {
843
+ throw new RangeError('Invalid argument');
844
+ }
845
+ this.bitData = bitData.slice(); // Make defensive copy
846
+ }
847
+ /* -- Methods -- */
848
+ // Returns a new copy of the data bits of this segment.
849
+ getData() {
850
+ return this.bitData.slice(); // Make defensive copy
851
+ }
852
+ // (Package-private) Calculates and returns the number of bits needed to encode the given segments at
853
+ // the given version. The result is infinity if a segment has too many characters to fit its length field.
854
+ static getTotalBits(segs, version) {
855
+ let result = 0;
856
+ for (const seg of segs) {
857
+ const ccbits = seg.mode.numCharCountBits(version);
858
+ if (seg.numChars >= 1 << ccbits) {
859
+ return Infinity;
860
+ } // The segment's length doesn't fit the field's bit width
861
+ result += 4 + ccbits + seg.bitData.length;
862
+ }
863
+ return result;
864
+ }
865
+ // Returns a new array of bytes representing the given string encoded in UTF-8.
866
+ static toUtf8ByteArray(str) {
867
+ str = encodeURI(str);
868
+ const result = [];
869
+ for (let i = 0; i < str.length; i++) {
870
+ if (str.charAt(i) !== '%') {
871
+ result.push(str.charCodeAt(i));
872
+ }
873
+ else {
874
+ result.push(Number.parseInt(str.substr(i + 1, 2), 16));
875
+ i += 2;
876
+ }
877
+ }
878
+ return result;
879
+ }
880
+ }
881
+ /* -- Constants -- */
882
+ // Describes precisely all strings that are encodable in numeric mode.
883
+ QrSegment.NUMERIC_REGEX = /^[0-9]*$/;
884
+ // Describes precisely all strings that are encodable in alphanumeric mode.
885
+ QrSegment.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+./:-]*$/;
886
+ // The set of all legal characters in alphanumeric mode,
887
+ // where each character value maps to the index in the string.
888
+ QrSegment.ALPHANUMERIC_CHARSET = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:';
889
+ qrcodegen.QrSegment = QrSegment;
890
+ })(qrcodegen || (qrcodegen = {}));
891
+ /* ---- Public helper enumeration ---- */
892
+ (function (qrcodegen) {
893
+ var QrCode;
894
+ (function (QrCode) {
895
+ /*
896
+ * The error correction level in a QR Code symbol. Immutable.
897
+ */
898
+ class Ecc {
899
+ /* -- Constructor and fields -- */
900
+ constructor(
901
+ // In the range 0 to 3 (unsigned 2-bit integer).
902
+ ordinal,
903
+ // (Package-private) In the range 0 to 3 (unsigned 2-bit integer).
904
+ formatBits) {
905
+ this.ordinal = ordinal;
906
+ this.formatBits = formatBits;
907
+ }
908
+ }
909
+ /* -- Constants -- */
910
+ Ecc.LOW = new Ecc(0, 1); // The QR Code can tolerate about 7% erroneous codewords
911
+ Ecc.MEDIUM = new Ecc(1, 0); // The QR Code can tolerate about 15% erroneous codewords
912
+ Ecc.QUARTILE = new Ecc(2, 3); // The QR Code can tolerate about 25% erroneous codewords
913
+ Ecc.HIGH = new Ecc(3, 2); // The QR Code can tolerate about 30% erroneous codewords
914
+ QrCode.Ecc = Ecc;
915
+ })(QrCode = qrcodegen.QrCode || (qrcodegen.QrCode = {}));
916
+ })(qrcodegen || (qrcodegen = {}));
917
+ /* ---- Public helper enumeration ---- */
918
+ (function (qrcodegen) {
919
+ var QrSegment;
920
+ (function (QrSegment) {
921
+ /*
922
+ * Describes how a segment's data bits are interpreted. Immutable.
923
+ */
924
+ class Mode {
925
+ /* -- Constructor and fields -- */
926
+ constructor(
927
+ // The mode indicator bits, which is a uint4 value (range 0 to 15).
928
+ modeBits,
929
+ // Number of character count bits for three different version ranges.
930
+ numBitsCharCount) {
931
+ this.modeBits = modeBits;
932
+ this.numBitsCharCount = numBitsCharCount;
933
+ }
934
+ /* -- Method -- */
935
+ // (Package-private) Returns the bit width of the character count field for a segment in
936
+ // this mode in a QR Code at the given version number. The result is in the range [0, 16].
937
+ numCharCountBits(ver) {
938
+ return this.numBitsCharCount[Math.floor((ver + 7) / 17)];
939
+ }
940
+ }
941
+ /* -- Constants -- */
942
+ Mode.NUMERIC = new Mode(0x1, [10, 12, 14]);
943
+ Mode.ALPHANUMERIC = new Mode(0x2, [9, 11, 13]);
944
+ Mode.BYTE = new Mode(0x4, [8, 16, 16]);
945
+ Mode.KANJI = new Mode(0x8, [8, 10, 12]);
946
+ Mode.ECI = new Mode(0x7, [0, 0, 0]);
947
+ QrSegment.Mode = Mode;
948
+ })(QrSegment = qrcodegen.QrSegment || (qrcodegen.QrSegment = {}));
949
+ })(qrcodegen || (qrcodegen = {}));
950
+ exports.default = qrcodegen;