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