tempest-react-sdk 0.38.2 → 0.38.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/lib/design/collect.mjs +19 -0
- package/bin/lib/design/functions.mjs +5 -0
- package/bin/lib/design/index.mjs +8 -3
- package/bin/lib/design/index.test.mjs +31 -0
- package/bin/lib/design/scan.mjs +34 -2
- package/bin/lib/design/scan.test.mjs +78 -0
- package/bin/lib/doctor/doctor.e2e.test.mjs +85 -0
- package/bin/tempest.mjs +90 -6
- package/dist/audio/level-meter.cjs.map +1 -1
- package/dist/audio/level-meter.js.map +1 -1
- package/dist/audio/use-audio-recorder.cjs.map +1 -1
- package/dist/audio/use-audio-recorder.js.map +1 -1
- package/dist/auth/passkey.cjs.map +1 -1
- package/dist/auth/passkey.js.map +1 -1
- package/dist/auth/use-passkey.cjs.map +1 -1
- package/dist/auth/use-passkey.js.map +1 -1
- package/dist/br/BrazilMap.cjs.map +1 -1
- package/dist/br/BrazilMap.js.map +1 -1
- package/dist/br/BrazilStateCitySelect.cjs.map +1 -1
- package/dist/br/BrazilStateCitySelect.js.map +1 -1
- package/dist/br/BrazilStateMap.cjs.map +1 -1
- package/dist/br/BrazilStateMap.js.map +1 -1
- package/dist/br/PixQRCode.cjs.map +1 -1
- package/dist/br/PixQRCode.js.map +1 -1
- package/dist/br/boleto.cjs.map +1 -1
- package/dist/br/boleto.js.map +1 -1
- package/dist/br/pix.cjs.map +1 -1
- package/dist/br/pix.js.map +1 -1
- package/dist/br.d.ts +8 -0
- package/dist/capture/media-recorder.cjs.map +1 -1
- package/dist/capture/media-recorder.js.map +1 -1
- package/dist/capture/use-barcode-scanner.cjs.map +1 -1
- package/dist/capture/use-barcode-scanner.js.map +1 -1
- package/dist/capture/use-screen-capture.cjs.map +1 -1
- package/dist/capture/use-screen-capture.js.map +1 -1
- package/dist/capture/use-speech-recognition.cjs.map +1 -1
- package/dist/capture/use-speech-recognition.js.map +1 -1
- package/dist/capture/use-video-recorder.cjs.map +1 -1
- package/dist/capture/use-video-recorder.js.map +1 -1
- package/dist/charts/types.cjs.map +1 -1
- package/dist/charts/types.js.map +1 -1
- package/dist/charts.d.ts +8 -0
- package/dist/components/AIChat/AIChat.cjs.map +1 -1
- package/dist/components/AIChat/AIChat.js.map +1 -1
- package/dist/components/AIChat/AIChatComposer.cjs.map +1 -1
- package/dist/components/AIChat/AIChatComposer.js.map +1 -1
- package/dist/components/AIChat/AIChatTurn.cjs.map +1 -1
- package/dist/components/AIChat/AIChatTurn.js.map +1 -1
- package/dist/components/AppBar/AppBar.cjs.map +1 -1
- package/dist/components/AppBar/AppBar.js.map +1 -1
- package/dist/components/AudioPlayer/AudioPlayer.cjs.map +1 -1
- package/dist/components/AudioPlayer/AudioPlayer.js.map +1 -1
- package/dist/components/AudioRecorder/AudioRecorder.cjs.map +1 -1
- package/dist/components/AudioRecorder/AudioRecorder.js.map +1 -1
- package/dist/components/BarcodeScanner/BarcodeScanner.cjs.map +1 -1
- package/dist/components/BarcodeScanner/BarcodeScanner.js.map +1 -1
- package/dist/components/Button/Button.cjs.map +1 -1
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Calendar/Calendar.cjs.map +1 -1
- package/dist/components/Calendar/Calendar.js.map +1 -1
- package/dist/components/Carousel/Carousel.cjs.map +1 -1
- package/dist/components/Carousel/Carousel.js.map +1 -1
- package/dist/components/Chat/Chat.cjs.map +1 -1
- package/dist/components/Chat/Chat.js.map +1 -1
- package/dist/components/ChipInput/ChipInput.cjs.map +1 -1
- package/dist/components/ChipInput/ChipInput.js.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.cjs.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.js.map +1 -1
- package/dist/components/Combobox/Combobox.cjs.map +1 -1
- package/dist/components/Combobox/Combobox.js.map +1 -1
- package/dist/components/Command/Command.cjs.map +1 -1
- package/dist/components/Command/Command.js.map +1 -1
- package/dist/components/ConfirmDialog/ConfirmDialog.cjs.map +1 -1
- package/dist/components/ConfirmDialog/ConfirmDialog.js.map +1 -1
- package/dist/components/ContextMenu/ContextMenu.cjs.map +1 -1
- package/dist/components/ContextMenu/ContextMenu.js.map +1 -1
- package/dist/components/CopyButton/CopyButton.cjs.map +1 -1
- package/dist/components/CopyButton/CopyButton.js.map +1 -1
- package/dist/components/DataTable/DataTable.cjs.map +1 -1
- package/dist/components/DataTable/DataTable.js.map +1 -1
- package/dist/components/DataTable/DataTable.module.cjs.map +1 -1
- package/dist/components/DataTable/DataTable.module.js.map +1 -1
- package/dist/components/DataTable/EditableCell.cjs.map +1 -1
- package/dist/components/DataTable/EditableCell.js.map +1 -1
- package/dist/components/DatePicker/DatePicker.cjs.map +1 -1
- package/dist/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.cjs.map +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/components/Drawer/Drawer.cjs.map +1 -1
- package/dist/components/Drawer/Drawer.js.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.cjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.js.map +1 -1
- package/dist/components/Dropzone/Dropzone.cjs.map +1 -1
- package/dist/components/Dropzone/Dropzone.js.map +1 -1
- package/dist/components/FileUpload/FileUpload.cjs.map +1 -1
- package/dist/components/FileUpload/FileUpload.js.map +1 -1
- package/dist/components/FilterBar/FilterBar.cjs.map +1 -1
- package/dist/components/FilterBar/FilterBar.js.map +1 -1
- package/dist/components/ImageCropper/ImageCropper.cjs.map +1 -1
- package/dist/components/ImageCropper/ImageCropper.js.map +1 -1
- package/dist/components/InstallBanner/InstallBanner.cjs.map +1 -1
- package/dist/components/InstallBanner/InstallBanner.js.map +1 -1
- package/dist/components/Kanban/Kanban.cjs.map +1 -1
- package/dist/components/Kanban/Kanban.js.map +1 -1
- package/dist/components/Lightbox/Lightbox.cjs.map +1 -1
- package/dist/components/Lightbox/Lightbox.js.map +1 -1
- package/dist/components/ListTile/ListTile.cjs.map +1 -1
- package/dist/components/ListTile/ListTile.js.map +1 -1
- package/dist/components/Markdown/Markdown.cjs.map +1 -1
- package/dist/components/Markdown/Markdown.js.map +1 -1
- package/dist/components/Markdown/markdown-parse.cjs.map +1 -1
- package/dist/components/Markdown/markdown-parse.js.map +1 -1
- package/dist/components/Menubar/Menubar.cjs.map +1 -1
- package/dist/components/Menubar/Menubar.js.map +1 -1
- package/dist/components/Modal/Modal.cjs.map +1 -1
- package/dist/components/Modal/Modal.js.map +1 -1
- package/dist/components/ModalsManager/ModalsManager.cjs.map +1 -1
- package/dist/components/ModalsManager/ModalsManager.js.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.cjs.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.js.map +1 -1
- package/dist/components/NavigationMenu/NavigationMenu.cjs.map +1 -1
- package/dist/components/NavigationMenu/NavigationMenu.js.map +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.cjs.map +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.js.map +1 -1
- package/dist/components/Page/Page.cjs.map +1 -1
- package/dist/components/Page/Page.js.map +1 -1
- package/dist/components/Pagination/Pagination.cjs.map +1 -1
- package/dist/components/Pagination/Pagination.js.map +1 -1
- package/dist/components/PasswordInput/PasswordInput.cjs.map +1 -1
- package/dist/components/PasswordInput/PasswordInput.js.map +1 -1
- package/dist/components/PinInput/PinInput.cjs.map +1 -1
- package/dist/components/PinInput/PinInput.js.map +1 -1
- package/dist/components/Popover/Popover.cjs.map +1 -1
- package/dist/components/Popover/Popover.js.map +1 -1
- package/dist/components/Progress/Progress.cjs.map +1 -1
- package/dist/components/Progress/Progress.js.map +1 -1
- package/dist/components/QRCode/qr-encode.cjs.map +1 -1
- package/dist/components/QRCode/qr-encode.js.map +1 -1
- package/dist/components/Radio/Radio.cjs.map +1 -1
- package/dist/components/Radio/Radio.js.map +1 -1
- package/dist/components/RangeSlider/RangeSlider.cjs.map +1 -1
- package/dist/components/RangeSlider/RangeSlider.js.map +1 -1
- package/dist/components/RatingStars/RatingStars.cjs.map +1 -1
- package/dist/components/RatingStars/RatingStars.js.map +1 -1
- package/dist/components/RefreshIndicator/RefreshIndicator.cjs.map +1 -1
- package/dist/components/RefreshIndicator/RefreshIndicator.js.map +1 -1
- package/dist/components/Resizable/Resizable.cjs.map +1 -1
- package/dist/components/Resizable/Resizable.js.map +1 -1
- package/dist/components/Scheduler/Scheduler.cjs.map +1 -1
- package/dist/components/Scheduler/Scheduler.js.map +1 -1
- package/dist/components/Sidebar/Sidebar.cjs.map +1 -1
- package/dist/components/Sidebar/Sidebar.js.map +1 -1
- package/dist/components/SignaturePad/SignaturePad.cjs.map +1 -1
- package/dist/components/SignaturePad/SignaturePad.js.map +1 -1
- package/dist/components/Slider/Slider.cjs.map +1 -1
- package/dist/components/Slider/Slider.js.map +1 -1
- package/dist/components/Sparkline/Sparkline.cjs.map +1 -1
- package/dist/components/Sparkline/Sparkline.js.map +1 -1
- package/dist/components/StepperInput/StepperInput.cjs.map +1 -1
- package/dist/components/StepperInput/StepperInput.js.map +1 -1
- package/dist/components/Table/Table.cjs.map +1 -1
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/TimePicker/TimePicker.cjs.map +1 -1
- package/dist/components/TimePicker/TimePicker.js.map +1 -1
- package/dist/components/Toast/ToastProvider.cjs.map +1 -1
- package/dist/components/Toast/ToastProvider.js.map +1 -1
- package/dist/components/Tour/Tour.cjs.map +1 -1
- package/dist/components/Tour/Tour.js.map +1 -1
- package/dist/components/Transfer/Transfer.cjs.map +1 -1
- package/dist/components/Transfer/Transfer.js.map +1 -1
- package/dist/components/TreeView/TreeView.cjs.map +1 -1
- package/dist/components/TreeView/TreeView.js.map +1 -1
- package/dist/components/VirtualList/VirtualList.cjs.map +1 -1
- package/dist/components/VirtualList/VirtualList.js.map +1 -1
- package/dist/components/VirtualTable/VirtualTable.cjs.map +1 -1
- package/dist/components/VirtualTable/VirtualTable.js.map +1 -1
- package/dist/components/Wizard/Wizard.cjs.map +1 -1
- package/dist/components/Wizard/Wizard.js.map +1 -1
- package/dist/editor/RichTextEditor.cjs.map +1 -1
- package/dist/editor/RichTextEditor.js.map +1 -1
- package/dist/forms/FormField.cjs.map +1 -1
- package/dist/forms/FormField.js.map +1 -1
- package/dist/geo/TrajectoryMap.cjs.map +1 -1
- package/dist/geo/TrajectoryMap.js.map +1 -1
- package/dist/geo/estimate.cjs.map +1 -1
- package/dist/geo/estimate.js.map +1 -1
- package/dist/geo/projection.cjs.map +1 -1
- package/dist/geo/projection.js.map +1 -1
- package/dist/hooks/use-event-listener.cjs.map +1 -1
- package/dist/hooks/use-event-listener.js.map +1 -1
- package/dist/hooks/use-local-storage.cjs.map +1 -1
- package/dist/hooks/use-local-storage.js.map +1 -1
- package/dist/hooks/use-sortable.cjs.map +1 -1
- package/dist/hooks/use-sortable.js.map +1 -1
- package/dist/http/api-client.cjs.map +1 -1
- package/dist/http/api-client.js.map +1 -1
- package/dist/http/errors.cjs.map +1 -1
- package/dist/http/errors.js.map +1 -1
- package/dist/http/resumable-upload.cjs.map +1 -1
- package/dist/http/resumable-upload.js.map +1 -1
- package/dist/http/upload-with-progress.cjs.map +1 -1
- package/dist/http/upload-with-progress.js.map +1 -1
- package/dist/i18n/I18nProvider.cjs.map +1 -1
- package/dist/i18n/I18nProvider.js.map +1 -1
- package/dist/imaging/canvas.cjs.map +1 -1
- package/dist/imaging/canvas.js.map +1 -1
- package/dist/imaging.d.ts +5 -0
- package/dist/logger/logger.cjs.map +1 -1
- package/dist/logger/logger.js.map +1 -1
- package/dist/oauth/GoogleSignIn.cjs.map +1 -1
- package/dist/oauth/GoogleSignIn.js.map +1 -1
- package/dist/offline/create-offline-sync.cjs.map +1 -1
- package/dist/offline/create-offline-sync.js.map +1 -1
- package/dist/perf/cache-size.cjs +1 -1
- package/dist/perf/cache-size.cjs.map +1 -1
- package/dist/perf/cache-size.js +27 -6
- package/dist/perf/cache-size.js.map +1 -1
- package/dist/sse/create-event-stream.cjs.map +1 -1
- package/dist/sse/create-event-stream.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/sw/background-sync.cjs.map +1 -1
- package/dist/sw/background-sync.js.map +1 -1
- package/dist/sw/cache.cjs.map +1 -1
- package/dist/sw/cache.js.map +1 -1
- package/dist/sw.d.ts +12 -0
- package/dist/tabular/compact.cjs.map +1 -1
- package/dist/tabular/compact.js.map +1 -1
- package/dist/tabular/predictor.cjs.map +1 -1
- package/dist/tabular/predictor.js.map +1 -1
- package/dist/tabular.d.ts +7 -2
- package/dist/tempest-react-sdk.d.ts +133 -6
- package/dist/theme/ThemeProvider.cjs.map +1 -1
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/dist/theme/color.cjs.map +1 -1
- package/dist/theme/color.js.map +1 -1
- package/dist/theme/create-theme.cjs.map +1 -1
- package/dist/theme/create-theme.js.map +1 -1
- package/dist/theme/data-viz-ramps.cjs +1 -1
- package/dist/theme/data-viz-ramps.cjs.map +1 -1
- package/dist/theme/data-viz-ramps.js +1 -1
- package/dist/theme/data-viz-ramps.js.map +1 -1
- package/dist/utils/storage.cjs.map +1 -1
- package/dist/utils/storage.js.map +1 -1
- package/dist/vision/core/canvas.cjs.map +1 -1
- package/dist/vision/core/canvas.js.map +1 -1
- package/dist/vision/core/exceptions.cjs.map +1 -1
- package/dist/vision/core/exceptions.js.map +1 -1
- package/dist/vision/core/graph.cjs.map +1 -1
- package/dist/vision/core/graph.js.map +1 -1
- package/dist/vision/core/metadata.cjs.map +1 -1
- package/dist/vision/core/metadata.js.map +1 -1
- package/dist/vision/core/providers.cjs.map +1 -1
- package/dist/vision/core/providers.js.map +1 -1
- package/dist/vision/core/session.cjs.map +1 -1
- package/dist/vision/core/session.js.map +1 -1
- package/dist/vision/core/timing.cjs.map +1 -1
- package/dist/vision/core/timing.js.map +1 -1
- package/dist/vision/io/image.cjs.map +1 -1
- package/dist/vision/io/image.js.map +1 -1
- package/dist/vision/labels.cjs.map +1 -1
- package/dist/vision/labels.js.map +1 -1
- package/dist/vision/luminance.cjs.map +1 -1
- package/dist/vision/luminance.js.map +1 -1
- package/dist/vision/postprocess/classification.cjs.map +1 -1
- package/dist/vision/postprocess/classification.js.map +1 -1
- package/dist/vision/postprocess/detection.cjs.map +1 -1
- package/dist/vision/postprocess/detection.js.map +1 -1
- package/dist/vision/postprocess/segmentation.cjs.map +1 -1
- package/dist/vision/postprocess/segmentation.js.map +1 -1
- package/dist/vision/preprocess/image.cjs.map +1 -1
- package/dist/vision/preprocess/image.js.map +1 -1
- package/dist/vision/results.cjs.map +1 -1
- package/dist/vision/results.js.map +1 -1
- package/dist/vision/tasks/base.cjs.map +1 -1
- package/dist/vision/tasks/base.js.map +1 -1
- package/dist/vision/tasks/classifier.cjs.map +1 -1
- package/dist/vision/tasks/classifier.js.map +1 -1
- package/dist/vision/tasks/detector.cjs.map +1 -1
- package/dist/vision/tasks/detector.js.map +1 -1
- package/dist/vision/tasks/segmenter.cjs.map +1 -1
- package/dist/vision/tasks/segmenter.js.map +1 -1
- package/dist/vision/types.cjs.map +1 -1
- package/dist/vision/types.js.map +1 -1
- package/dist/vision.d.ts +6 -0
- package/dist/vite/tempest-icons.cjs.map +1 -1
- package/dist/vite/tempest-icons.js.map +1 -1
- package/dist/vite/tempest-pwa-icons.cjs.map +1 -1
- package/dist/vite/tempest-pwa-icons.js.map +1 -1
- package/dist/ws/create-web-socket.cjs.map +1 -1
- package/dist/ws/create-web-socket.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordInput.cjs","names":[],"sources":["../../../src/components/PasswordInput/PasswordInput.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"PasswordInput.cjs","names":[],"sources":["../../../src/components/PasswordInput/PasswordInput.tsx"],"sourcesContent":["/**\n * @tempest-limits props-count — on top of the SDK's shared field props,\n * showStrength/strength/strengthLabels are the meter and toggleLabels is the\n * show/hide button's accessible name — both need their copy from the app, since\n * neither can be translated by the SDK.\n */\nimport { forwardRef, useId, useState } from \"react\";\nimport type { InputHTMLAttributes, ReactNode } from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport styles from \"./PasswordInput.module.css\";\n\nexport type PasswordStrength = 0 | 1 | 2 | 3 | 4;\n\nexport interface PasswordInputProps extends Omit<\n InputHTMLAttributes<HTMLInputElement>,\n \"type\" | \"size\"\n> {\n /** Label rendered above the input. */\n label?: ReactNode;\n /** Helper text below — replaced by `error` when set. */\n helperText?: ReactNode;\n /** Error message. Adds `aria-invalid` + red border. */\n error?: string;\n /** Visual size of the input. */\n size?: \"sm\" | \"md\" | \"lg\";\n /** Show a strength meter below the field. Default `false`. */\n showStrength?: boolean;\n /** Override the automatic strength calc (0–4). */\n strength?: PasswordStrength;\n /** Custom labels per strength level (5 entries). */\n strengthLabels?: readonly [string, string, string, string, string];\n /** Custom toggle button labels for accessibility. */\n toggleLabels?: { show: string; hide: string };\n}\n\nconst DEFAULT_STRENGTH_LABELS = [\"Muito fraca\", \"Fraca\", \"Razoável\", \"Forte\", \"Excelente\"] as const;\n\nexport function estimatePasswordStrength(value: string): PasswordStrength {\n if (!value) return 0;\n let score = 0;\n if (value.length >= 8) score += 1;\n if (value.length >= 12) score += 1;\n if (/[a-z]/.test(value) && /[A-Z]/.test(value)) score += 1;\n if (/[0-9]/.test(value)) score += 1;\n if (/[^A-Za-z0-9]/.test(value)) score += 1;\n return Math.min(4, score) as PasswordStrength;\n}\n\n/**\n * Password field with toggle-visibility button and optional strength meter.\n *\n * @example\n * <PasswordInput label=\"Senha\" showStrength autoComplete=\"new-password\" />\n */\nexport const PasswordInput = forwardRef<HTMLInputElement, PasswordInputProps>(\n function PasswordInput(\n {\n label,\n helperText,\n error,\n size = \"md\",\n showStrength = false,\n strength,\n strengthLabels = DEFAULT_STRENGTH_LABELS,\n toggleLabels = { show: \"Mostrar senha\", hide: \"Esconder senha\" },\n className,\n value,\n defaultValue,\n id,\n ...inputProps\n },\n ref,\n ) {\n const generatedId = useId();\n const inputId = id ?? generatedId;\n const describedById = error\n ? `${inputId}-error`\n : helperText\n ? `${inputId}-helper`\n : undefined;\n const [revealed, setRevealed] = useState<boolean>(false);\n const stringValue = String((value ?? defaultValue ?? \"\") as string);\n const computedStrength: PasswordStrength =\n strength ?? estimatePasswordStrength(stringValue);\n\n return (\n <div className={cn(styles.wrapper, styles[size], error && styles.error, className)}>\n {label && (\n <label htmlFor={inputId} className={styles.label}>\n {label}\n </label>\n )}\n <div className={styles.field}>\n <input\n ref={ref}\n {...inputProps}\n id={inputId}\n value={value}\n defaultValue={defaultValue}\n type={revealed ? \"text\" : \"password\"}\n aria-invalid={!!error}\n aria-describedby={describedById}\n className={styles.input}\n />\n <button\n type=\"button\"\n className={styles.toggle}\n aria-label={revealed ? toggleLabels.hide : toggleLabels.show}\n aria-pressed={revealed}\n onClick={() => setRevealed((on) => !on)}\n >\n {revealed ? \"🙈\" : \"👁\"}\n </button>\n </div>\n {showStrength && (\n <div\n className={cn(styles.strength, styles[`level${computedStrength}`])}\n aria-label={strengthLabels[computedStrength]}\n >\n <div className={styles.strengthBar}>\n <span style={{ width: `${(computedStrength / 4) * 100}%` }} />\n </div>\n <span className={styles.strengthLabel}>\n {strengthLabels[computedStrength]}\n </span>\n </div>\n )}\n {error ? (\n <span id={`${inputId}-error`} className={styles.errorText}>\n {error}\n </span>\n ) : helperText ? (\n <span id={`${inputId}-helper`} className={styles.helper}>\n {helperText}\n </span>\n ) : null}\n </div>\n );\n },\n);\n"],"mappings":"oIAmCA,IAAM,EAA0B,CAAC,cAAe,QAAS,WAAY,QAAS,WAAW,EAEzF,SAAgB,EAAyB,EAAiC,CACtE,GAAI,CAAC,EAAO,MAAO,GACnB,IAAI,EAAQ,EAMZ,OALI,EAAM,QAAU,IAAG,GAAS,GAC5B,EAAM,QAAU,KAAI,GAAS,GAC7B,QAAQ,KAAK,CAAK,GAAK,QAAQ,KAAK,CAAK,IAAG,GAAS,GACrD,QAAQ,KAAK,CAAK,IAAG,GAA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AAO,SAAU,EAAA,QAAO,QAAQ,IAAmB,EACjE,aAAY,EAAe,YAF/B,EAII,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAW,EAAA,QAAO,sBACnB,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,MAAO,CAAE,MAAO,GAAI,EAAmB,EAAK,IAAI,EAAG,CAAI,CAAA,CAC5D,CAAA,GACL,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAW,EAAA,QAAO,uBACnB,EAAe,EACd,CAAA,CACL,IAER,GACG,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,GAAI,GAAG,EAAQ,QAAS,UAAW,EAAA,QAAO,mBAC3C,CACC,CAAA,EACN,GACA,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,GAAI,GAAG,EAAQ,SAAU,UAAW,EAAA,QAAO,gBAC5C,CACC,CAAA,EACN,IACH,GAEb,CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordInput.js","names":[],"sources":["../../../src/components/PasswordInput/PasswordInput.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"PasswordInput.js","names":[],"sources":["../../../src/components/PasswordInput/PasswordInput.tsx"],"sourcesContent":["/**\n * @tempest-limits props-count — on top of the SDK's shared field props,\n * showStrength/strength/strengthLabels are the meter and toggleLabels is the\n * show/hide button's accessible name — both need their copy from the app, since\n * neither can be translated by the SDK.\n */\nimport { forwardRef, useId, useState } from \"react\";\nimport type { InputHTMLAttributes, ReactNode } from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport styles from \"./PasswordInput.module.css\";\n\nexport type PasswordStrength = 0 | 1 | 2 | 3 | 4;\n\nexport interface PasswordInputProps extends Omit<\n InputHTMLAttributes<HTMLInputElement>,\n \"type\" | \"size\"\n> {\n /** Label rendered above the input. */\n label?: ReactNode;\n /** Helper text below — replaced by `error` when set. */\n helperText?: ReactNode;\n /** Error message. Adds `aria-invalid` + red border. */\n error?: string;\n /** Visual size of the input. */\n size?: \"sm\" | \"md\" | \"lg\";\n /** Show a strength meter below the field. Default `false`. */\n showStrength?: boolean;\n /** Override the automatic strength calc (0–4). */\n strength?: PasswordStrength;\n /** Custom labels per strength level (5 entries). */\n strengthLabels?: readonly [string, string, string, string, string];\n /** Custom toggle button labels for accessibility. */\n toggleLabels?: { show: string; hide: string };\n}\n\nconst DEFAULT_STRENGTH_LABELS = [\"Muito fraca\", \"Fraca\", \"Razoável\", \"Forte\", \"Excelente\"] as const;\n\nexport function estimatePasswordStrength(value: string): PasswordStrength {\n if (!value) return 0;\n let score = 0;\n if (value.length >= 8) score += 1;\n if (value.length >= 12) score += 1;\n if (/[a-z]/.test(value) && /[A-Z]/.test(value)) score += 1;\n if (/[0-9]/.test(value)) score += 1;\n if (/[^A-Za-z0-9]/.test(value)) score += 1;\n return Math.min(4, score) as PasswordStrength;\n}\n\n/**\n * Password field with toggle-visibility button and optional strength meter.\n *\n * @example\n * <PasswordInput label=\"Senha\" showStrength autoComplete=\"new-password\" />\n */\nexport const PasswordInput = forwardRef<HTMLInputElement, PasswordInputProps>(\n function PasswordInput(\n {\n label,\n helperText,\n error,\n size = \"md\",\n showStrength = false,\n strength,\n strengthLabels = DEFAULT_STRENGTH_LABELS,\n toggleLabels = { show: \"Mostrar senha\", hide: \"Esconder senha\" },\n className,\n value,\n defaultValue,\n id,\n ...inputProps\n },\n ref,\n ) {\n const generatedId = useId();\n const inputId = id ?? generatedId;\n const describedById = error\n ? `${inputId}-error`\n : helperText\n ? `${inputId}-helper`\n : undefined;\n const [revealed, setRevealed] = useState<boolean>(false);\n const stringValue = String((value ?? defaultValue ?? \"\") as string);\n const computedStrength: PasswordStrength =\n strength ?? estimatePasswordStrength(stringValue);\n\n return (\n <div className={cn(styles.wrapper, styles[size], error && styles.error, className)}>\n {label && (\n <label htmlFor={inputId} className={styles.label}>\n {label}\n </label>\n )}\n <div className={styles.field}>\n <input\n ref={ref}\n {...inputProps}\n id={inputId}\n value={value}\n defaultValue={defaultValue}\n type={revealed ? \"text\" : \"password\"}\n aria-invalid={!!error}\n aria-describedby={describedById}\n className={styles.input}\n />\n <button\n type=\"button\"\n className={styles.toggle}\n aria-label={revealed ? toggleLabels.hide : toggleLabels.show}\n aria-pressed={revealed}\n onClick={() => setRevealed((on) => !on)}\n >\n {revealed ? \"🙈\" : \"👁\"}\n </button>\n </div>\n {showStrength && (\n <div\n className={cn(styles.strength, styles[`level${computedStrength}`])}\n aria-label={strengthLabels[computedStrength]}\n >\n <div className={styles.strengthBar}>\n <span style={{ width: `${(computedStrength / 4) * 100}%` }} />\n </div>\n <span className={styles.strengthLabel}>\n {strengthLabels[computedStrength]}\n </span>\n </div>\n )}\n {error ? (\n <span id={`${inputId}-error`} className={styles.errorText}>\n {error}\n </span>\n ) : helperText ? (\n <span id={`${inputId}-helper`} className={styles.helper}>\n {helperText}\n </span>\n ) : null}\n </div>\n );\n },\n);\n"],"mappings":";;;;;AAmCA,IAAM,IAA0B;CAAC;CAAe;CAAS;CAAY;CAAS;AAAW;AAEzF,SAAgB,EAAyB,GAAiC;CACtE,IAAI,CAAC,GAAO,OAAO;CACnB,IAAI,IAAQ;CAMZ,OALI,EAAM,UAAU,MAAG,KAAS,IAC5B,EAAM,UAAU,OAAI,KAAS,IAC7B,QAAQ,KAAK,CAAK,KAAK,QAAQ,KAAK,CAAK,MAAG,KAAS,IACrD,QAAQ,KAAK,CAAK,MAAG,KAAS,IAC9B,eAAe,KAAK,CAAK,MAAG,KAAS,IAClC,KAAK,IAAI,GAAG,CAAK;AAC5B;AAQA,IAAa,IAAgB,EACzB,SACI,EACI,UACA,eACA,UACA,UAAO,MACP,kBAAe,IACf,aACA,oBAAiB,GACjB,kBAAe;CAAE,MAAM;CAAiB,MAAM;AAAiB,GAC/D,cACA,UACA,iBACA,OACA,GAAG,KAEP,GACF;CACE,IAAM,IAAc,EAAM,GACpB,IAAU,KAAM,GAChB,IAAgB,IAChB,GAAG,EAAQ,UACX,IACE,GAAG,EAAQ,WACX,KAAA,GACF,CAAC,GAAU,KAAe,EAAkB,EAAK,GAEjD,IACF,KAAY,EAFI,OAAQ,KAAS,KAAgB,EAEZ,CAAW;CAEpD,OACI,kBAAC,OAAD;EAAK,WAAW,EAAG,EAAO,SAAS,EAAO,IAAO,KAAS,EAAO,OAAO,CAAS;YAAjF;GACK,KACG,kBAAC,SAAD;IAAO,SAAS;IAAS,WAAW,EAAO;cACtC;GACE,CAAA;GAEX,kBAAC,OAAD;IAAK,WAAW,EAAO;cAAvB,CACI,kBAAC,SAAD;KACS;KACL,GAAI;KACJ,IAAI;KACG;KACO;KACd,MAAM,IAAW,SAAS;KAC1B,gBAAc,CAAC,CAAC;KAChB,oBAAkB;KAClB,WAAW,EAAO;IACrB,CAAA,GACD,kBAAC,UAAD;KACI,MAAK;KACL,WAAW,EAAO;KAClB,cAAY,IAAW,EAAa,OAAO,EAAa;KACxD,gBAAc;KACd,eAAe,GAAa,MAAO,CAAC,CAAE;eAErC,IAAW,OAAO;IACf,CAAA,CACP;;GACJ,KACG,kBAAC,OAAD;IACI,WAAW,EAAG,EAAO,UAAU,EAAO,QAAQ,IAAmB;IACjE,cAAY,EAAe;cAF/B,CAII,kBAAC,OAAD;KAAK,WAAW,EAAO;eACnB,kBAAC,QAAD,EAAM,OAAO,EAAE,OAAO,GAAI,IAAmB,IAAK,IAAI,GAAG,EAAI,CAAA;IAC5D,CAAA,GACL,kBAAC,QAAD;KAAM,WAAW,EAAO;eACnB,EAAe;IACd,CAAA,CACL;;GAER,IACG,kBAAC,QAAD;IAAM,IAAI,GAAG,EAAQ;IAAS,WAAW,EAAO;cAC3C;GACC,CAAA,IACN,IACA,kBAAC,QAAD;IAAM,IAAI,GAAG,EAAQ;IAAU,WAAW,EAAO;cAC5C;GACC,CAAA,IACN;EACH;;AAEb,CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PinInput.cjs","names":[],"sources":["../../../src/components/PinInput/PinInput.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"PinInput.cjs","names":[],"sources":["../../../src/components/PinInput/PinInput.tsx"],"sourcesContent":["/**\n * @tempest-limits props-count, function-lines — one input per digit, so length,\n * type, masked and autoFocus shape the boxes while\n * value/defaultValue/onChange/onComplete drive them as a single value. The body owns\n * the per-box refs, paste distribution and backspace traversal, which only make\n * sense with the whole array in scope.\n */\nimport { forwardRef, useEffect, useId, useRef, useState } from \"react\";\nimport type { ChangeEvent, ClipboardEvent, KeyboardEvent } from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport styles from \"./PinInput.module.css\";\n\nexport type PinInputType = \"numeric\" | \"alphanumeric\";\nexport type PinInputSize = \"sm\" | \"md\" | \"lg\";\n\nexport interface PinInputProps {\n /** Number of cells. Default `6`. */\n length?: number;\n /** Allowed character set. `numeric` (default) rejects letters, `alphanumeric` allows both. */\n type?: PinInputType;\n /** Visual size. Default `\"md\"`. */\n size?: PinInputSize;\n /** Controlled value. */\n value?: string;\n /** Initial value (uncontrolled mode). */\n defaultValue?: string;\n /** Fires on every change with the current concatenated value. */\n onChange?: (value: string) => void;\n /** Fires when the user fills the last cell. */\n onComplete?: (value: string) => void;\n /** Show characters obscured (`*`). Default `false`. */\n masked?: boolean;\n /** Label rendered above the cells. */\n label?: string;\n /** Helper text below the cells. */\n helperText?: string;\n /** Error message — turns cells red and replaces helperText. */\n error?: string;\n /** Disable all cells. */\n disabled?: boolean;\n /** Auto-focus the first cell on mount. Default `false`. */\n autoFocus?: boolean;\n /** id for the wrapping group label association. */\n id?: string;\n className?: string;\n}\n\nconst NUMERIC = /[0-9]/;\nconst ALNUM = /[A-Za-z0-9]/;\n\n/**\n * One-time-password style input — N independent cells, paste support, auto-\n * advance on input, backspace flows back, arrow keys navigate.\n *\n * @example\n * <PinInput length={6} type=\"numeric\" onComplete={(otp) => verify(otp)} />\n */\nexport const PinInput = forwardRef<HTMLDivElement, PinInputProps>(function PinInput(\n {\n length = 6,\n type = \"numeric\",\n size = \"md\",\n value,\n defaultValue,\n onChange,\n onComplete,\n masked = false,\n label,\n helperText,\n error,\n disabled = false,\n autoFocus = false,\n id,\n className,\n },\n ref,\n) {\n const internalId = useId();\n const wrapperId = id ?? internalId;\n const isControlled = value !== undefined;\n const [internal, setInternal] = useState<string>(defaultValue ?? \"\");\n const current = isControlled ? (value ?? \"\") : internal;\n const cells = Array.from({ length }, (_, index) => current[index] ?? \"\");\n const inputsRef = useRef<(HTMLInputElement | null)[]>([]);\n const pattern = type === \"numeric\" ? NUMERIC : ALNUM;\n\n useEffect(() => {\n if (autoFocus) inputsRef.current[0]?.focus();\n }, [autoFocus]);\n\n const update = (next: string): void => {\n const trimmed = next.slice(0, length);\n if (!isControlled) setInternal(trimmed);\n onChange?.(trimmed);\n if (trimmed.length === length) onComplete?.(trimmed);\n };\n\n const focusCell = (index: number): void => {\n const safe = Math.max(0, Math.min(length - 1, index));\n inputsRef.current[safe]?.focus();\n inputsRef.current[safe]?.select();\n };\n\n const onCellChange = (index: number) => (event: ChangeEvent<HTMLInputElement>) => {\n const char = event.target.value.slice(-1);\n if (char && !pattern.test(char)) return;\n const next = cells.slice();\n next[index] = char;\n update(next.join(\"\"));\n if (char) focusCell(index + 1);\n };\n\n const onCellKeyDown = (index: number) => (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === \"Backspace\") {\n if (!cells[index] && index > 0) {\n event.preventDefault();\n const next = cells.slice();\n next[index - 1] = \"\";\n update(next.join(\"\"));\n focusCell(index - 1);\n }\n } else if (event.key === \"ArrowLeft\") {\n event.preventDefault();\n focusCell(index - 1);\n } else if (event.key === \"ArrowRight\") {\n event.preventDefault();\n focusCell(index + 1);\n }\n };\n\n const onPaste = (event: ClipboardEvent<HTMLInputElement>): void => {\n const text = event.clipboardData\n .getData(\"text\")\n .split(\"\")\n .filter((c) => pattern.test(c))\n .join(\"\");\n if (!text) return;\n event.preventDefault();\n update(text);\n focusCell(Math.min(length - 1, text.length));\n };\n\n return (\n <div\n ref={ref}\n className={cn(styles.wrapper, error && styles.error, className)}\n id={wrapperId}\n >\n {label && <label className={styles.label}>{label}</label>}\n <div className={cn(styles.cells, styles[size])} role=\"group\" aria-label={label}>\n {cells.map((cell, index) => (\n <input\n key={index}\n ref={(node) => {\n inputsRef.current[index] = node;\n }}\n type={masked ? \"password\" : \"text\"}\n inputMode={type === \"numeric\" ? \"numeric\" : \"text\"}\n autoComplete={index === 0 ? \"one-time-code\" : \"off\"}\n maxLength={1}\n value={cell}\n disabled={disabled}\n className={styles.cell}\n aria-label={`Dígito ${index + 1}`}\n aria-invalid={!!error}\n onChange={onCellChange(index)}\n onKeyDown={onCellKeyDown(index)}\n onPaste={onPaste}\n />\n ))}\n </div>\n {error ? (\n <span className={styles.errorText}>{error}</span>\n ) : helperText ? (\n <span className={styles.helper}>{helperText}</span>\n ) : null}\n </div>\n );\n});\n"],"mappings":"+HA+CA,IAAM,EAAU,QACV,EAAQ,cASD,GAAA,EAAA,EAAA,WAAA,CAAqD,SAC9D,CACI,SAAS,EACT,OAAO,UACP,OAAO,KACP,QACA,eACA,WACA,aACA,SAAS,GACT,QACA,aACA,QACA,WAAW,GACX,YAAY,GACZ,KACA,aAEJ,EACF,CACE,IAAM,GAAA,EAAA,EAAA,MAAA,CAAmB,EACnB,EAAY,GAAM,EAClB,EAAe,IAAU,IAAA,GACzB,CAAC,EAAU,IAAA,EAAA,EAAA,SAAA,CAAgC,GAAgB,EAAE,EAC7D,EAAU,EAAgB,GAAS,GAAM,EACzC,EAAQ,MAAM,KAAK,CAAE,QAAO,GAAI,EAAG,IAAU,EAAQ,IAAU,EAAE,EACjE,GAAA,EAAA,EAAA,OAAA,CAAgD,CAAC,CAAC,EAClD,EAAU,IAAS,UAAY,EAAU,GAE/C,EAAA,EAAA,UAAA,KAAgB,CACR,GAAW,EAAU,QAAQ,EAAE,EAAE,MAAM,CAC/C,EAAG,CAAC,CAAS,CAAC,EAEd,IAAM,EAAU,GAAuB,CACnC,IAAM,EAAU,EAAK,MAAM,EAAG,CA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,QAAO,MAAO,CAAS,EAC9D,GAAI,WAHR,CAKK,IAAS,EAAA,EAAA,IAAA,CAAC,QAAD,CAAO,UAAW,EAAA,QAAO,eAAQ,CAAa,CAAA,GACxD,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAW,EAAA,GAAG,EAAA,QAAO,MAAO,EAAA,QAAO,EAAK,EAAG,KAAK,QAAQ,aAAY,WACpE,EAAM,KAAK,EAAM,KACd,EAAA,EAAA,IAAA,CAAC,QAAD,CAEI,IAAM,GAAS,CACX,EAAU,QAAQ,GAAS,CAC/B,EACA,KAAM,EAAS,WAAa,OAC5B,UAAW,IAAS,UAAY,UAAY,OAC5C,aAAc,IAAU,EAAI,gBAAkB,MAC9C,UAAW,EACX,MAAO,EACG,WACV,UAAW,EAAA,QAAO,KAClB,aAAY,UAAU,EAAQ,IAC9B,eAAc,CAAC,CAAC,EAChB,SAAU,EAAa,CAAK,EAC5B,UAAW,EAAc,CAAK,EACrB,SACZ,EAhBQ,CAgBR,CACJ,CACA,CAAA,EACJ,GACG,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAW,EAAA,QAAO,mBAAY,CAAY,CAAA,EAChD,GACA,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAW,EAAA,QAAO,gBAAS,CAAiB,CAAA,EAClD,IACH,GAEb,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PinInput.js","names":[],"sources":["../../../src/components/PinInput/PinInput.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"PinInput.js","names":[],"sources":["../../../src/components/PinInput/PinInput.tsx"],"sourcesContent":["/**\n * @tempest-limits props-count, function-lines — one input per digit, so length,\n * type, masked and autoFocus shape the boxes while\n * value/defaultValue/onChange/onComplete drive them as a single value. The body owns\n * the per-box refs, paste distribution and backspace traversal, which only make\n * sense with the whole array in scope.\n */\nimport { forwardRef, useEffect, useId, useRef, useState } from \"react\";\nimport type { ChangeEvent, ClipboardEvent, KeyboardEvent } from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport styles from \"./PinInput.module.css\";\n\nexport type PinInputType = \"numeric\" | \"alphanumeric\";\nexport type PinInputSize = \"sm\" | \"md\" | \"lg\";\n\nexport interface PinInputProps {\n /** Number of cells. Default `6`. */\n length?: number;\n /** Allowed character set. `numeric` (default) rejects letters, `alphanumeric` allows both. */\n type?: PinInputType;\n /** Visual size. Default `\"md\"`. */\n size?: PinInputSize;\n /** Controlled value. */\n value?: string;\n /** Initial value (uncontrolled mode). */\n defaultValue?: string;\n /** Fires on every change with the current concatenated value. */\n onChange?: (value: string) => void;\n /** Fires when the user fills the last cell. */\n onComplete?: (value: string) => void;\n /** Show characters obscured (`*`). Default `false`. */\n masked?: boolean;\n /** Label rendered above the cells. */\n label?: string;\n /** Helper text below the cells. */\n helperText?: string;\n /** Error message — turns cells red and replaces helperText. */\n error?: string;\n /** Disable all cells. */\n disabled?: boolean;\n /** Auto-focus the first cell on mount. Default `false`. */\n autoFocus?: boolean;\n /** id for the wrapping group label association. */\n id?: string;\n className?: string;\n}\n\nconst NUMERIC = /[0-9]/;\nconst ALNUM = /[A-Za-z0-9]/;\n\n/**\n * One-time-password style input — N independent cells, paste support, auto-\n * advance on input, backspace flows back, arrow keys navigate.\n *\n * @example\n * <PinInput length={6} type=\"numeric\" onComplete={(otp) => verify(otp)} />\n */\nexport const PinInput = forwardRef<HTMLDivElement, PinInputProps>(function PinInput(\n {\n length = 6,\n type = \"numeric\",\n size = \"md\",\n value,\n defaultValue,\n onChange,\n onComplete,\n masked = false,\n label,\n helperText,\n error,\n disabled = false,\n autoFocus = false,\n id,\n className,\n },\n ref,\n) {\n const internalId = useId();\n const wrapperId = id ?? internalId;\n const isControlled = value !== undefined;\n const [internal, setInternal] = useState<string>(defaultValue ?? \"\");\n const current = isControlled ? (value ?? \"\") : internal;\n const cells = Array.from({ length }, (_, index) => current[index] ?? \"\");\n const inputsRef = useRef<(HTMLInputElement | null)[]>([]);\n const pattern = type === \"numeric\" ? NUMERIC : ALNUM;\n\n useEffect(() => {\n if (autoFocus) inputsRef.current[0]?.focus();\n }, [autoFocus]);\n\n const update = (next: string): void => {\n const trimmed = next.slice(0, length);\n if (!isControlled) setInternal(trimmed);\n onChange?.(trimmed);\n if (trimmed.length === length) onComplete?.(trimmed);\n };\n\n const focusCell = (index: number): void => {\n const safe = Math.max(0, Math.min(length - 1, index));\n inputsRef.current[safe]?.focus();\n inputsRef.current[safe]?.select();\n };\n\n const onCellChange = (index: number) => (event: ChangeEvent<HTMLInputElement>) => {\n const char = event.target.value.slice(-1);\n if (char && !pattern.test(char)) return;\n const next = cells.slice();\n next[index] = char;\n update(next.join(\"\"));\n if (char) focusCell(index + 1);\n };\n\n const onCellKeyDown = (index: number) => (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === \"Backspace\") {\n if (!cells[index] && index > 0) {\n event.preventDefault();\n const next = cells.slice();\n next[index - 1] = \"\";\n update(next.join(\"\"));\n focusCell(index - 1);\n }\n } else if (event.key === \"ArrowLeft\") {\n event.preventDefault();\n focusCell(index - 1);\n } else if (event.key === \"ArrowRight\") {\n event.preventDefault();\n focusCell(index + 1);\n }\n };\n\n const onPaste = (event: ClipboardEvent<HTMLInputElement>): void => {\n const text = event.clipboardData\n .getData(\"text\")\n .split(\"\")\n .filter((c) => pattern.test(c))\n .join(\"\");\n if (!text) return;\n event.preventDefault();\n update(text);\n focusCell(Math.min(length - 1, text.length));\n };\n\n return (\n <div\n ref={ref}\n className={cn(styles.wrapper, error && styles.error, className)}\n id={wrapperId}\n >\n {label && <label className={styles.label}>{label}</label>}\n <div className={cn(styles.cells, styles[size])} role=\"group\" aria-label={label}>\n {cells.map((cell, index) => (\n <input\n key={index}\n ref={(node) => {\n inputsRef.current[index] = node;\n }}\n type={masked ? \"password\" : \"text\"}\n inputMode={type === \"numeric\" ? \"numeric\" : \"text\"}\n autoComplete={index === 0 ? \"one-time-code\" : \"off\"}\n maxLength={1}\n value={cell}\n disabled={disabled}\n className={styles.cell}\n aria-label={`Dígito ${index + 1}`}\n aria-invalid={!!error}\n onChange={onCellChange(index)}\n onKeyDown={onCellKeyDown(index)}\n onPaste={onPaste}\n />\n ))}\n </div>\n {error ? (\n <span className={styles.errorText}>{error}</span>\n ) : helperText ? (\n <span className={styles.helper}>{helperText}</span>\n ) : null}\n </div>\n );\n});\n"],"mappings":";;;;;AA+CA,IAAM,IAAU,SACV,IAAQ,eASD,IAAW,EAA0C,SAC9D,EACI,YAAS,GACT,UAAO,WACP,UAAO,MACP,UACA,iBACA,aACA,eACA,YAAS,IACT,UACA,eACA,UACA,cAAW,IACX,eAAY,IACZ,OACA,gBAEJ,GACF;CACE,IAAM,IAAa,EAAM,GACnB,IAAY,KAAM,GAClB,IAAe,MAAU,KAAA,GACzB,CAAC,GAAU,KAAe,EAAiB,KAAgB,EAAE,GAC7D,IAAU,IAAgB,KAAS,KAAM,GACzC,IAAQ,MAAM,KAAK,EAAE,UAAO,IAAI,GAAG,MAAU,EAAQ,MAAU,EAAE,GACjE,IAAY,EAAoC,CAAC,CAAC,GAClD,IAAU,MAAS,YAAY,IAAU;CAE/C,QAAgB;EACZ,AAAI,KAAW,EAAU,QAAQ,EAAE,EAAE,MAAM;CAC/C,GAAG,CAAC,CAAS,CAAC;CAEd,IAAM,KAAU,MAAuB;EACnC,IAAM,IAAU,EAAK,MAAM,GAAG,CAAM;EAGpC,AAFK,KAAc,EAAY,CAAO,GACtC,IAAW,CAAO,GACd,EAAQ,WAAW,KAAQ,IAAa,CAAO;CACvD,GAEM,KAAa,MAAwB;EACvC,IAAM,IAAO,KAAK,IAAI,GAAG,KAAK,IAAI,IAAS,GAAG,CAAK,CAAC;EAEpD,AADA,EAAU,QAAQ,EAAK,EAAE,MAAM,GAC/B,EAAU,QAAQ,EAAK,EAAE,OAAO;CACpC,GAEM,KAAgB,OAAmB,MAAyC;EAC9E,IAAM,IAAO,EAAM,OAAO,MAAM,MAAM,EAAE;EACxC,IAAI,KAAQ,CAA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W;KACX,OAAO;KACG;KACV,WAAW,EAAO;KAClB,cAAY,UAAU,IAAQ;KAC9B,gBAAc,CAAC,CAAC;KAChB,UAAU,EAAa,CAAK;KAC5B,WAAW,EAAc,CAAK;KACrB;IACZ,GAhBQ,CAgBR,CACJ;GACA,CAAA;GACJ,IACG,kBAAC,QAAD;IAAM,WAAW,EAAO;cAAY;GAAY,CAAA,IAChD,IACA,kBAAC,QAAD;IAAM,WAAW,EAAO;cAAS;GAAiB,CAAA,IAClD;EACH;;AAEb,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.cjs","names":[],"sources":["../../../src/components/Popover/Popover.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"Popover.cjs","names":[],"sources":["../../../src/components/Popover/Popover.tsx"],"sourcesContent":["/**\n * @tempest-limits props-count — trigger and children are the two halves, placement\n * is where it lands, and open/onOpenChange/defaultOpen is the standard controlled-\n * or-not pair. closeOnEsc and closeOnOutsideClick are separate because a popover\n * holding a form wants one and not the other.\n */\nimport { useCallback, useEffect, useId, useRef, useState } from \"react\";\nimport type { ReactElement, ReactNode } from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport styles from \"./Popover.module.css\";\n\nexport type PopoverPlacement = \"top\" | \"bottom\" | \"left\" | \"right\";\n\nexport interface PopoverProps {\n /** Trigger element. Receives `onClick`/`aria-expanded`/`aria-controls`. */\n trigger: ReactElement<{\n onClick?: (e: React.MouseEvent) => void;\n \"aria-expanded\"?: boolean;\n \"aria-controls\"?: string;\n }>;\n children: ReactNode;\n placement?: PopoverPlacement;\n /** Controlled open state. */\n open?: boolean;\n /** Called when the user toggles or dismisses. */\n onOpenChange?: (open: boolean) => void;\n /** Default open state for uncontrolled usage. */\n defaultOpen?: boolean;\n /** Close on Escape. Default true. */\n closeOnEsc?: boolean;\n /** Close on outside click. Default true. */\n closeOnOutsideClick?: boolean;\n className?: string;\n}\n\n/**\n * Lightweight popover. Renders a positioned panel anchored to a trigger,\n * dismissed on outside click / Escape. Does NOT include collision detection\n * or smart positioning — pair with Floating UI if you need that.\n */\nexport function Popover({\n trigger,\n children,\n placement = \"bottom\",\n open,\n onOpenChange,\n defaultOpen = false,\n closeOnEsc = true,\n closeOnOutsideClick = true,\n className,\n}: PopoverProps) {\n const isControlled = open !== undefined;\n const [internalOpen, setInternalOpen] = useState<boolean>(defaultOpen);\n const isOpen = isControlled ? open : internalOpen;\n const id = useId();\n const rootRef = useRef<HTMLSpanElement>(null);\n\n const setOpen = useCallback(\n (next: boolean): void => {\n if (!isControlled) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [isControlled, onOpenChange],\n );\n\n useEffect(() => {\n if (!isOpen) return;\n const onKey = (event: KeyboardEvent): void => {\n if (closeOnEsc && event.key === \"Escape\") setOpen(false);\n };\n const onDown = (event: MouseEvent): void => {\n if (!closeOnOutsideClick) return;\n if (rootRef.current && !rootRef.current.contains(event.target as Node)) {\n setOpen(false);\n }\n };\n window.addEventListener(\"keydown\", onKey);\n window.addEventListener(\"mousedown\", onDown);\n return () => {\n window.removeEventListener(\"keydown\", onKey);\n window.removeEventListener(\"mousedown\", onDown);\n };\n }, [isOpen, closeOnEsc, closeOnOutsideClick, setOpen]);\n\n const handleTriggerClick = (event: React.MouseEvent): void => {\n trigger.props.onClick?.(event);\n setOpen(!isOpen);\n };\n\n const triggerClone = {\n ...trigger,\n props: {\n ...trigger.props,\n onClick: handleTriggerClick,\n \"aria-expanded\": isOpen,\n \"aria-controls\": id,\n },\n } as ReactElement;\n\n return (\n <span ref={rootRef} className={styles.root}>\n {triggerClone}\n {isOpen && (\n <div\n id={id}\n role=\"dialog\"\n className={cn(styles.popover, styles[placement], className)}\n >\n {children}\n </div>\n )}\n </span>\n );\n}\n"],"mappings":"8HAwCA,SAAgB,EAAQ,CACpB,UACA,WACA,YAAY,SACZ,OACA,eACA,cAAc,GACd,aAAa,GACb,sBAAsB,GACtB,aACa,CACb,IAAM,EAAe,IAAS,IAAA,GACxB,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popover.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"Popover.js","names":[],"sources":["../../../src/components/Popover/Popover.tsx"],"sourcesContent":["/**\n * @tempest-limits props-count — trigger and children are the two halves, placement\n * is where it lands, and open/onOpenChange/defaultOpen is the standard controlled-\n * or-not pair. closeOnEsc and closeOnOutsideClick are separate because a popover\n * holding a form wants one and not the other.\n */\nimport { useCallback, useEffect, useId, useRef, useState } from \"react\";\nimport type { ReactElement, ReactNode } from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport styles from \"./Popover.module.css\";\n\nexport type PopoverPlacement = \"top\" | \"bottom\" | \"left\" | \"right\";\n\nexport interface PopoverProps {\n /** Trigger element. Receives `onClick`/`aria-expanded`/`aria-controls`. */\n trigger: ReactElement<{\n onClick?: (e: React.MouseEvent) => void;\n \"aria-expanded\"?: boolean;\n \"aria-controls\"?: string;\n }>;\n children: ReactNode;\n placement?: PopoverPlacement;\n /** Controlled open state. */\n open?: boolean;\n /** Called when the user toggles or dismisses. */\n onOpenChange?: (open: boolean) => void;\n /** Default open state for uncontrolled usage. */\n defaultOpen?: boolean;\n /** Close on Escape. Default true. */\n closeOnEsc?: boolean;\n /** Close on outside click. Default true. */\n closeOnOutsideClick?: boolean;\n className?: string;\n}\n\n/**\n * Lightweight popover. Renders a positioned panel anchored to a trigger,\n * dismissed on outside click / Escape. Does NOT include collision detection\n * or smart positioning — pair with Floating UI if you need that.\n */\nexport function Popover({\n trigger,\n children,\n placement = \"bottom\",\n open,\n onOpenChange,\n defaultOpen = false,\n closeOnEsc = true,\n closeOnOutsideClick = true,\n className,\n}: PopoverProps) {\n const isControlled = open !== undefined;\n const [internalOpen, setInternalOpen] = useState<boolean>(defaultOpen);\n const isOpen = isControlled ? open : internalOpen;\n const id = useId();\n const rootRef = useRef<HTMLSpanElement>(null);\n\n const setOpen = useCallback(\n (next: boolean): void => {\n if (!isControlled) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [isControlled, onOpenChange],\n );\n\n useEffect(() => {\n if (!isOpen) return;\n const onKey = (event: KeyboardEvent): void => {\n if (closeOnEsc && event.key === \"Escape\") setOpen(false);\n };\n const onDown = (event: MouseEvent): void => {\n if (!closeOnOutsideClick) return;\n if (rootRef.current && !rootRef.current.contains(event.target as Node)) {\n setOpen(false);\n }\n };\n window.addEventListener(\"keydown\", onKey);\n window.addEventListener(\"mousedown\", onDown);\n return () => {\n window.removeEventListener(\"keydown\", onKey);\n window.removeEventListener(\"mousedown\", onDown);\n };\n }, [isOpen, closeOnEsc, closeOnOutsideClick, setOpen]);\n\n const handleTriggerClick = (event: React.MouseEvent): void => {\n trigger.props.onClick?.(event);\n setOpen(!isOpen);\n };\n\n const triggerClone = {\n ...trigger,\n props: {\n ...trigger.props,\n onClick: handleTriggerClick,\n \"aria-expanded\": isOpen,\n \"aria-controls\": id,\n },\n } as ReactElement;\n\n return (\n <span ref={rootRef} className={styles.root}>\n {triggerClone}\n {isOpen && (\n <div\n id={id}\n role=\"dialog\"\n className={cn(styles.popover, styles[placement], className)}\n >\n {children}\n </div>\n )}\n </span>\n );\n}\n"],"mappings":";;;;;AAwCA,SAAgB,EAAQ,EACpB,YACA,aACA,eAAY,UACZ,SACA,iBACA,iBAAc,IACd,gBAAa,IACb,yBAAsB,IACtB,gBACa;CACb,IAAM,IAAe,MAAS,KAAA,GACxB,CAAC,GAAc,KAAmB,EAAkB,CAAW,GAC/D,IAAS,IAAe,IAAO,GAC/B,IAAK,EAAM,GACX,IAAU,EAAwB,IAAI,GAEtC,IAAU,GACX,MAAwB;EAErB,AADK,KAAc,EAAgB,CAAI,GACvC,IAAe,CAAI;CACvB,GACA,CAAC,GAAc,CAAY,CAC/B;CAEA,QAAgB;EACZ,IAAI,CAAC,GAAQ;EACb,IAAM,KAAS,MAA+B;GAC1C,AAAI,KAAc,EAAM,QAAQ,YAAU,EAAQ,EAAK;EAC3D,GACM,KAAU,MAA4B;GACnC,KACD,EAAQ,WAAW,CAAC,EAAQ,QAAQ,SAAS,EAAM,MAAc,KACjE,EAAQ,EAAK;EAErB;EAGA,OAFA,OAAO,iBAAiB,WAAW,CAAK,GACxC,OAAO,iBAAiB,aAAa,CAAM,SAC9B;GAET,AADA,OAAO,oBAAoB,WAAW,CAAK,GAC3C,OAAO,oBAAoB,aAAa,CAAM;EAClD;CACJ,GAAG;EAAC;EAAQ;EAAY;EAAqB;CAAO,CAAC;CAErD,IAAM,KAAsB,MAAkC;EAE1D,AADA,EAAQ,MAAM,UAAU,CAAK,GAC7B,EAAQ,CAAC,CAAM;CACnB,GAEM,IAAe;EACjB,GAAG;EACH,OAAO;GACH,GAAG,EAAQ;GACX,SAAS;GACT,iBAAiB;GACjB,iBAAiB;EACrB;CACJ;CAEA,OACI,kBAAC,QAAD;EAAM,KAAK;EAAS,WAAW,EAAO;YAAtC,CACK,GACA,KACG,kBAAC,OAAD;GACQ;GACJ,MAAK;GACL,WAAW,EAAG,EAAO,SAAS,EAAO,IAAY,CAAS;GAEzD;EACA,CAAA,CAEP;;AAEd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Progress.cjs","names":[],"sources":["../../../src/components/Progress/Progress.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"Progress.cjs","names":[],"sources":["../../../src/components/Progress/Progress.tsx"],"sourcesContent":["/**\n * @tempest-limits props-count — value, max, indeterminate, size, tone, label,\n * showValue and className: a progress bar is one element with eight independent\n * presentation choices, and the destructuring counts them all because none has a\n * sensible sub-object.\n */\nimport { cn } from \"@/utils/cn\";\nimport styles from \"./Progress.module.css\";\n\nexport type ProgressVariant = \"primary\" | \"success\" | \"warning\" | \"danger\";\n\nexport interface ProgressProps {\n /** Value between 0 and `max` (or 0-100 by default). Ignored when `indeterminate`. */\n value?: number;\n max?: number;\n variant?: ProgressVariant;\n /** Show an animated indeterminate bar. Default: false. */\n indeterminate?: boolean;\n /** Render a numeric label \"x% / max\" above the bar. Default: false. */\n showLabel?: boolean;\n /** Optional left-aligned descriptor (e.g. \"Enviando arquivo…\"). */\n label?: string;\n /**\n * Accessible name for the bar. Defaults to `label` when that is set —\n * provide it explicitly whenever the bar renders without a visible label,\n * otherwise screen readers announce an unnamed progressbar.\n */\n \"aria-label\"?: string;\n /** Id of an existing element that names the bar (alternative to `aria-label`). */\n \"aria-labelledby\"?: string;\n className?: string;\n}\n\n/**\n * Linear progress bar with determinate / indeterminate modes.\n *\n * The `progressbar` role requires an accessible name: it comes from\n * `aria-labelledby`, then explicit `aria-label`, then the visible `label`.\n */\nexport function Progress({\n value = 0,\n max = 100,\n variant = \"primary\",\n indeterminate = false,\n showLabel = false,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n className,\n}: ProgressProps) {\n const pct = indeterminate ? 0 : Math.max(0, Math.min(100, (value / max) * 100));\n\n return (\n <div className={cn(styles.wrapper, className)}>\n {(showLabel || label) && (\n <div className={styles.label}>\n {label && <span>{label}</span>}\n {showLabel && !indeterminate && <span>{Math.round(pct)}%</span>}\n </div>\n )}\n <div\n role=\"progressbar\"\n aria-label={ariaLabelledBy ? undefined : (ariaLabel ?? label)}\n aria-labelledby={ariaLabelledBy}\n aria-valuemin={0}\n aria-valuemax={max}\n aria-valuenow={indeterminate ? undefined : value}\n className={cn(styles.bar, indeterminate && styles.indeterminate)}\n >\n <div\n className={cn(styles.fill, variant !== \"primary\" && styles[variant])}\n style={{ width: indeterminate ? undefined : `${pct}%` }}\n />\n </div>\n </div>\n );\n}\n"],"mappings":"4GAuCA,SAAgB,EAAS,CACrB,QAAQ,EACR,MAAM,IACN,UAAU,UACV,gBAAgB,GAChB,YAAY,GACZ,QACA,aAAc,EACd,kBAAmB,EACnB,aACc,CACd,IAAM,EAAM,EAAgB,EAAI,KAAK,IAAI,EAAG,KAAK,IAAI,IAAM,EAAQ,EAAO,GAAG,CAAC,EAE9E,OACI,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAW,EAAA,GAAG,EAAA,QAAO,QAAS,CAAS,WAA5C,EACM,GAAa,KACX,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAW,EAAA,QAAO,eAAvB,CACK,IAAS,EAAA,EAAA,IAAA,CAAC,OAAD,CAAA,SAAO,CAAY,CAAA,EAC5B,GAAa,CAAC,IAAiB,EAAA,EAAA,KAAA,CAAC,OAAD,CAAA,SAAA,CAAO,KAAK,MAAM,CAAG,EAAE,GAAO,CAAA,CAAA,CAC7D,KAET,EAAA,EAAA,IAAA,CAAC,MAAD,CACI,KAAK,cACL,aAAY,EAAiB,IAAA,GAAa,GAAa,EACvD,kBAAiB,EACjB,gBAAe,EACf,gBAAe,EACf,gBAAe,EAAgB,IAAA,GAAY,EAC3C,UAAW,EAAA,GAAG,EAAA,QAAO,IAAK,GAAiB,EAAA,QAAO,aAAa,YAE/D,EAAA,EAAA,IAAA,CAAC,MAAD,CACI,UAAW,EAAA,GAAG,EAAA,QAAO,KAAM,IAAY,WAAa,EAAA,QAAO,EAAQ,EACnE,MAAO,CAAE,MAAO,EAAgB,IAAA,GAAY,GAAG,EAAI,EAAG,CACzD,CAAA,CACA,CAAA,CACJ,GAEb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Progress.js","names":[],"sources":["../../../src/components/Progress/Progress.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"Progress.js","names":[],"sources":["../../../src/components/Progress/Progress.tsx"],"sourcesContent":["/**\n * @tempest-limits props-count — value, max, indeterminate, size, tone, label,\n * showValue and className: a progress bar is one element with eight independent\n * presentation choices, and the destructuring counts them all because none has a\n * sensible sub-object.\n */\nimport { cn } from \"@/utils/cn\";\nimport styles from \"./Progress.module.css\";\n\nexport type ProgressVariant = \"primary\" | \"success\" | \"warning\" | \"danger\";\n\nexport interface ProgressProps {\n /** Value between 0 and `max` (or 0-100 by default). Ignored when `indeterminate`. */\n value?: number;\n max?: number;\n variant?: ProgressVariant;\n /** Show an animated indeterminate bar. Default: false. */\n indeterminate?: boolean;\n /** Render a numeric label \"x% / max\" above the bar. Default: false. */\n showLabel?: boolean;\n /** Optional left-aligned descriptor (e.g. \"Enviando arquivo…\"). */\n label?: string;\n /**\n * Accessible name for the bar. Defaults to `label` when that is set —\n * provide it explicitly whenever the bar renders without a visible label,\n * otherwise screen readers announce an unnamed progressbar.\n */\n \"aria-label\"?: string;\n /** Id of an existing element that names the bar (alternative to `aria-label`). */\n \"aria-labelledby\"?: string;\n className?: string;\n}\n\n/**\n * Linear progress bar with determinate / indeterminate modes.\n *\n * The `progressbar` role requires an accessible name: it comes from\n * `aria-labelledby`, then explicit `aria-label`, then the visible `label`.\n */\nexport function Progress({\n value = 0,\n max = 100,\n variant = \"primary\",\n indeterminate = false,\n showLabel = false,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n className,\n}: ProgressProps) {\n const pct = indeterminate ? 0 : Math.max(0, Math.min(100, (value / max) * 100));\n\n return (\n <div className={cn(styles.wrapper, className)}>\n {(showLabel || label) && (\n <div className={styles.label}>\n {label && <span>{label}</span>}\n {showLabel && !indeterminate && <span>{Math.round(pct)}%</span>}\n </div>\n )}\n <div\n role=\"progressbar\"\n aria-label={ariaLabelledBy ? undefined : (ariaLabel ?? label)}\n aria-labelledby={ariaLabelledBy}\n aria-valuemin={0}\n aria-valuemax={max}\n aria-valuenow={indeterminate ? undefined : value}\n className={cn(styles.bar, indeterminate && styles.indeterminate)}\n >\n <div\n className={cn(styles.fill, variant !== \"primary\" && styles[variant])}\n style={{ width: indeterminate ? undefined : `${pct}%` }}\n />\n </div>\n </div>\n );\n}\n"],"mappings":";;;;AAuCA,SAAgB,EAAS,EACrB,WAAQ,GACR,SAAM,KACN,aAAU,WACV,mBAAgB,IAChB,eAAY,IACZ,UACA,cAAc,GACd,mBAAmB,GACnB,gBACc;CACd,IAAM,IAAM,IAAgB,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,KAAM,IAAQ,IAAO,GAAG,CAAC;CAE9E,OACI,kBAAC,OAAD;EAAK,WAAW,EAAG,EAAO,SAAS,CAAS;YAA5C,EACM,KAAa,MACX,kBAAC,OAAD;GAAK,WAAW,EAAO;aAAvB,CACK,KAAS,kBAAC,QAAD,EAAA,UAAO,EAAY,CAAA,GAC5B,KAAa,CAAC,KAAiB,kBAAC,QAAD,EAAA,UAAA,CAAO,KAAK,MAAM,CAAG,GAAE,GAAO,EAAA,CAAA,CAC7D;MAET,kBAAC,OAAD;GACI,MAAK;GACL,cAAY,IAAiB,KAAA,IAAa,KAAa;GACvD,mBAAiB;GACjB,iBAAe;GACf,iBAAe;GACf,iBAAe,IAAgB,KAAA,IAAY;GAC3C,WAAW,EAAG,EAAO,KAAK,KAAiB,EAAO,aAAa;aAE/D,kBAAC,OAAD;IACI,WAAW,EAAG,EAAO,MAAM,MAAY,aAAa,EAAO,EAAQ;IACnE,OAAO,EAAE,OAAO,IAAgB,KAAA,IAAY,GAAG,EAAI,GAAG;GACzD,CAAA;EACA,CAAA,CACJ;;AAEb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qr-encode.cjs","names":[],"sources":["../../../src/components/QRCode/qr-encode.ts"],"sourcesContent":["import {\n ALPHANUMERIC_CHARS,\n alignmentPatternPositions,\n dataCodewords,\n ECC_BLOCK_COUNT,\n ECC_CODEWORDS_PER_BLOCK,\n ECC_FORMAT_BITS,\n MAX_VERSION,\n MIN_VERSION,\n rawDataModules,\n type QRErrorCorrection,\n} from \"./qr-tables\";\n\nexport type { QRErrorCorrection };\n\n/** How the payload is packed into bits. */\nexport type QRMode = \"numeric\" | \"alphanumeric\" | \"byte\";\n\nexport interface QRMatrix {\n /** Side length in modules, including no quiet zone. */\n size: number;\n /** Row-major modules; `true` is dark. */\n modules: boolean[][];\n /** Symbol version, 1 to 40. */\n version: number;\n /** Level the symbol was encoded at. */\n level: QRErrorCorrection;\n /** The mode chosen for the payload. */\n mode: QRMode;\n /** Which of the eight masks scored best. */\n mask: number;\n}\n\nexport interface QREncodeOptions {\n /** Error correction level. Default `\"M\"`. */\n level?: QRErrorCorrection;\n /**\n * Force a minimum version. The encoder still grows past it when the payload\n * does not fit — a version is a floor, never a cap that silently truncates.\n */\n minVersion?: number;\n}\n\n/** Raised when a payload cannot be encoded at the requested level. */\nexport class QRCapacityError extends Error {\n constructor(\n readonly length: number,\n readonly level: QRErrorCorrection,\n ) {\n super(\n `Payload of ${length} bytes does not fit in a version-${MAX_VERSION} QR symbol at level ${level}. ` +\n \"Shorten the data, or drop to a lower correction level.\",\n );\n this.name = \"QRCapacityError\";\n }\n}\n\nconst MODE_INDICATOR: Record<QRMode, number> = { numeric: 1, alphanumeric: 2, byte: 4 };\n\nconst NUMERIC_RE = /^[0-9]*$/;\nconst ALPHANUMERIC_RE = /^[0-9A-Z $%*+\\-./:]*$/;\n\n/**\n * Pick the densest mode the payload qualifies for.\n *\n * Numeric packs 3 digits into 10 bits and alphanumeric 2 characters into 11, so\n * a phone number or an upper-case code encodes far smaller than the same string\n * as bytes — often a whole version smaller, which is a visibly coarser symbol\n * and therefore easier to scan.\n *\n * @param text - The payload.\n * @returns The narrowest mode that can represent it.\n */\nexport function selectMode(text: string): QRMode {\n if (NUMERIC_RE.test(text)) return \"numeric\";\n if (ALPHANUMERIC_RE.test(text)) return \"alphanumeric\";\n return \"byte\";\n}\n\n/** Bits the character-count field takes, which widens with the version. */\nfunction charCountBits(mode: QRMode, version: number): number {\n const tier = version <= 9 ? 0 : version <= 26 ? 1 : 2;\n if (mode === \"numeric\") return [10, 12, 14][tier];\n if (mode === \"alphanumeric\") return [9, 11, 13][tier];\n return [8, 16, 16][tier];\n}\n\n/** A bit sink that appends most-significant-bit first. */\nclass BitBuffer {\n readonly bits: number[] = [];\n\n append(value: number, length: number) {\n for (let i = length - 1; i >= 0; i--) this.bits.push((value >>> i) & 1);\n }\n\n get length(): number {\n return this.bits.length;\n }\n}\n\n/** UTF-8 bytes for the byte mode, so accents and emoji survive the round trip. */\nfunction utf8Bytes(text: string): number[] {\n return Array.from(new TextEncoder().encode(text));\n}\n\n/** Bits the payload itself occupies in a given mode, excluding the headers. */\nfunction payloadBits(text: string, mode: QRMode): number {\n if (mode === \"numeric\") {\n const groups = Math.floor(text.length / 3);\n const rest = text.length % 3;\n return groups * 10 + (rest === 0 ? 0 : rest === 1 ? 4 : 7);\n }\n if (mode === \"alphanumeric\") {\n return Math.floor(text.length / 2) * 11 + (text.length % 2) * 6;\n }\n return utf8Bytes(text).length * 8;\n}\n\n/** Write the payload into the buffer in the chosen mode. */\nfunction writePayload(buffer: BitBuffer, text: string, mode: QRMode) {\n if (mode === \"numeric\") {\n for (let i = 0; i < text.length; i += 3) {\n const chunk = text.slice(i, i + 3);\n buffer.append(Number(chunk), chunk.length * 3 + 1);\n }\n return;\n }\n if (mode === \"alphanumeric\") {\n for (let i = 0; i < text.length; i += 2) {\n const first = ALPHANUMERIC_CHARS.indexOf(text[i]);\n if (i + 1 === text.length) {\n buffer.append(first, 6);\n } else {\n buffer.append(first * 45 + ALPHANUMERIC_CHARS.indexOf(text[i + 1]), 11);\n }\n }\n return;\n }\n for (const byte of utf8Bytes(text)) buffer.append(byte, 8);\n}\n\n/** Character count for the header, which is bytes — not characters — in byte mode. */\nfunction headerCount(text: string, mode: QRMode): number {\n return mode === \"byte\" ? utf8Bytes(text).length : text.length;\n}\n\n/**\n * The smallest version that fits the payload at this level.\n *\n * @throws {QRCapacityError} When even version 40 is too small.\n */\nfunction selectVersion(\n text: string,\n mode: QRMode,\n level: QRErrorCorrection,\n minVersion: number,\n): number {\n const bits = payloadBits(text, mode);\n for (let version = Math.max(MIN_VERSION, minVersion); version <= MAX_VERSION; version++) {\n const capacity = dataCodewords(version, level) * 8;\n if (4 + charCountBits(mode, version) + bits <= capacity) return version;\n }\n throw new QRCapacityError(headerCount(text, mode), level);\n}\n\n// ── Reed-Solomon over GF(256), primitive polynomial 0x11D ───────────────────\n\nconst GF_EXP = new Uint8Array(512);\nconst GF_LOG = new Uint8Array(256);\n\n{\n let x = 1;\n for (let i = 0; i < 255; i++) {\n GF_EXP[i] = x;\n GF_LOG[x] = i;\n x = (x << 1) ^ (x & 0x80 ? 0x11d : 0);\n }\n for (let i = 255; i < 512; i++) GF_EXP[i] = GF_EXP[i - 255];\n}\n\nfunction gfMul(a: number, b: number): number {\n if (a === 0 || b === 0) return 0;\n return GF_EXP[GF_LOG[a] + GF_LOG[b]];\n}\n\n/** The generator polynomial for `degree` error-correction codewords. */\nfunction rsGenerator(degree: number): number[] {\n let poly = [1];\n for (let i = 0; i < degree; i++) {\n const next = new Array<number>(poly.length + 1).fill(0);\n for (let j = 0; j < poly.length; j++) {\n next[j] ^= poly[j];\n next[j + 1] ^= gfMul(poly[j], GF_EXP[i]);\n }\n poly = next;\n }\n return poly;\n}\n\n/**\n * The error-correction codewords for one block.\n *\n * @param data - The block's data codewords.\n * @param degree - How many correction codewords to produce.\n * @returns The remainder of the polynomial division, which is the ECC block.\n */\nexport function reedSolomon(data: readonly number[], degree: number): number[] {\n const generator = rsGenerator(degree);\n const remainder = new Array<number>(degree).fill(0);\n for (const byte of data) {\n const factor = byte ^ remainder[0];\n remainder.shift();\n remainder.push(0);\n for (let i = 0; i < degree; i++) {\n remainder[i] ^= gfMul(generator[i + 1], factor);\n }\n }\n return remainder;\n}\n\n/**\n * Split into blocks, add correction, and interleave into the final codeword\n * stream.\n *\n * Interleaving is what makes the correction useful against a real-world smudge:\n * a contiguous scratch on the printed symbol then damages a few codewords of\n * every block instead of destroying one block completely.\n */\nfunction buildCodewords(\n data: readonly number[],\n version: number,\n level: QRErrorCorrection,\n): number[] {\n const blockCount = ECC_BLOCK_COUNT[level][version - 1];\n const eccPerBlock = ECC_CODEWORDS_PER_BLOCK[level][version - 1];\n const totalCodewords = Math.floor(rawDataModules(version) / 8);\n const shortBlockLength = Math.floor(totalCodewords / blockCount) - eccPerBlock;\n const longBlockCount = totalCodewords % blockCount;\n\n const dataBlocks: number[][] = [];\n const eccBlocks: number[][] = [];\n let offset = 0;\n for (let i = 0; i < blockCount; i++) {\n const length = shortBlockLength + (i >= blockCount - longBlockCount ? 1 : 0);\n const block = data.slice(offset, offset + length);\n offset += length;\n dataBlocks.push(block);\n eccBlocks.push(reedSolomon(block, eccPerBlock));\n }\n\n const result: number[] = [];\n for (let i = 0; i < shortBlockLength + 1; i++) {\n for (const block of dataBlocks) {\n if (i < block.length) result.push(block[i]);\n }\n }\n for (let i = 0; i < eccPerBlock; i++) {\n for (const block of eccBlocks) result.push(block[i]);\n }\n return result;\n}\n\n// ── Matrix construction ─────────────────────────────────────────────────────\n\n/** A grid under construction: modules plus which cells are function patterns. */\ninterface Canvas {\n size: number;\n modules: boolean[][];\n reserved: boolean[][];\n}\n\nfunction createCanvas(version: number): Canvas {\n const size = version * 4 + 17;\n return {\n size,\n modules: Array.from({ length: size }, () => new Array<boolean>(size).fill(false)),\n reserved: Array.from({ length: size }, () => new Array<boolean>(size).fill(false)),\n };\n}\n\nfunction setModule(canvas: Canvas, x: number, y: number, dark: boolean, reserve = true) {\n if (x < 0 || y < 0 || x >= canvas.size || y >= canvas.size) return;\n canvas.modules[y][x] = dark;\n if (reserve) canvas.reserved[y][x] = true;\n}\n\n/** A finder pattern with its separator, anchored at a corner. */\nfunction drawFinder(canvas: Canvas, left: number, top: number) {\n for (let dy = -1; dy <= 7; dy++) {\n for (let dx = -1; dx <= 7; dx++) {\n const distance = Math.max(Math.abs(dx - 3), Math.abs(dy - 3));\n setModule(canvas, left + dx, top + dy, distance !== 2 && distance <= 3);\n }\n }\n}\n\nfunction drawAlignment(canvas: Canvas, cx: number, cy: number) {\n for (let dy = -2; dy <= 2; dy++) {\n for (let dx = -2; dx <= 2; dx++) {\n setModule(canvas, cx + dx, cy + dy, Math.max(Math.abs(dx), Math.abs(dy)) !== 1);\n }\n }\n}\n\nfunction drawFunctionPatterns(canvas: Canvas, version: number) {\n drawFinder(canvas, 0, 0);\n drawFinder(canvas, canvas.size - 7, 0);\n drawFinder(canvas, 0, canvas.size - 7);\n\n for (let i = 8; i < canvas.size - 8; i++) {\n const dark = i % 2 === 0;\n setModule(canvas, i, 6, dark);\n setModule(canvas, 6, i, dark);\n }\n\n const positions = alignmentPatternPositions(version);\n for (const cy of positions) {\n for (const cx of positions) {\n // The three corners already hold finder patterns.\n const atFinder =\n (cx === 6 && cy === 6) ||\n (cx === 6 && cy === canvas.size - 7) ||\n (cx === canvas.size - 7 && cy === 6);\n if (!atFinder) drawAlignment(canvas, cx, cy);\n }\n }\n\n // Reserve the format information, and light the always-dark module.\n for (let i = 0; i < 9; i++) {\n setModule(canvas, i, 8, false);\n setModule(canvas, 8, i, false);\n }\n for (let i = 0; i < 8; i++) {\n setModule(canvas, canvas.size - 1 - i, 8, false);\n setModule(canvas, 8, canvas.size - 1 - i, false);\n }\n setModule(canvas, 8, canvas.size - 8, true);\n\n if (version >= 7) {\n const value = versionInformation(version);\n for (let i = 0; i < 18; i++) {\n const bit = ((value >>> i) & 1) === 1;\n const a = canvas.size - 11 + (i % 3);\n const b = Math.floor(i / 3);\n setModule(canvas, a, b, bit);\n setModule(canvas, b, a, bit);\n }\n }\n}\n\n/** The 18-bit version information block, BCH(18,6) with generator 0x1F25. */\nfunction versionInformation(version: number): number {\n let remainder = version;\n for (let i = 0; i < 12; i++) {\n remainder = (remainder << 1) ^ ((remainder >>> 11) * 0x1f25);\n }\n return (version << 12) | remainder;\n}\n\n/** The 15-bit format information, BCH(15,5) masked with 0x5412. */\nfunction formatInformation(level: QRErrorCorrection, mask: number): number {\n const data = (ECC_FORMAT_BITS[level] << 3) | mask;\n let remainder = data;\n for (let i = 0; i < 10; i++) {\n remainder = (remainder << 1) ^ ((remainder >>> 9) * 0x537);\n }\n return ((data << 10) | remainder) ^ 0x5412;\n}\n\nfunction drawFormatInformation(canvas: Canvas, level: QRErrorCorrection, mask: number) {\n const bits = formatInformation(level, mask);\n\n for (let i = 0; i <= 5; i++) setModule(canvas, 8, i, ((bits >>> i) & 1) === 1);\n setModule(canvas, 8, 7, ((bits >>> 6) & 1) === 1);\n setModule(canvas, 8, 8, ((bits >>> 7) & 1) === 1);\n setModule(canvas, 7, 8, ((bits >>> 8) & 1) === 1);\n for (let i = 9; i < 15; i++) setModule(canvas, 14 - i, 8, ((bits >>> i) & 1) === 1);\n\n for (let i = 0; i < 8; i++) {\n setModule(canvas, canvas.size - 1 - i, 8, ((bits >>> i) & 1) === 1);\n }\n for (let i = 8; i < 15; i++) {\n setModule(canvas, 8, canvas.size - 15 + i, ((bits >>> i) & 1) === 1);\n }\n setModule(canvas, 8, canvas.size - 8, true);\n}\n\n/**\n * Lay the codeword stream into the free modules.\n *\n * The path is a boustrophedon over two-module columns from the bottom-right\n * corner, skipping the vertical timing pattern in column 6 entirely — that\n * column would otherwise shift every subsequent column by one.\n */\nfunction drawCodewords(canvas: Canvas, codewords: readonly number[]) {\n let bitIndex = 0;\n let upward = true;\n\n for (let right = canvas.size - 1; right >= 1; right -= 2) {\n if (right === 6) right = 5;\n for (let step = 0; step < canvas.size; step++) {\n const y = upward ? canvas.size - 1 - step : step;\n for (let column = 0; column < 2; column++) {\n const x = right - column;\n if (canvas.reserved[y][x]) continue;\n const byte = codewords[bitIndex >>> 3];\n // Remainder bits past the stream are light, per the standard.\n canvas.modules[y][x] =\n byte !== undefined && ((byte >>> (7 - (bitIndex & 7))) & 1) === 1;\n bitIndex++;\n }\n }\n upward = !upward;\n }\n}\n\nconst MASK_FUNCTIONS: readonly ((x: number, y: number) => boolean)[] = [\n (x, y) => (x + y) % 2 === 0,\n (_x, y) => y % 2 === 0,\n (x) => x % 3 === 0,\n (x, y) => (x + y) % 3 === 0,\n (x, y) => (Math.floor(y / 2) + Math.floor(x / 3)) % 2 === 0,\n (x, y) => ((x * y) % 2) + ((x * y) % 3) === 0,\n (x, y) => (((x * y) % 2) + ((x * y) % 3)) % 2 === 0,\n (x, y) => (((x + y) % 2) + ((x * y) % 3)) % 2 === 0,\n];\n\nfunction applyMask(canvas: Canvas, mask: number) {\n const fn = MASK_FUNCTIONS[mask];\n for (let y = 0; y < canvas.size; y++) {\n for (let x = 0; x < canvas.size; x++) {\n if (!canvas.reserved[y][x] && fn(x, y)) canvas.modules[y][x] = !canvas.modules[y][x];\n }\n }\n}\n\n/**\n * Score a masked symbol; lower is better.\n *\n * The four penalties push away from patterns a scanner confuses with the finder\n * marks, and from large flat areas where it cannot lock on.\n */\nfunction penalty(canvas: Canvas): number {\n const { size, modules } = canvas;\n let score = 0;\n\n const runPenalty = (run: number) => (run >= 5 ? 3 + (run - 5) : 0);\n\n for (let y = 0; y < size; y++) {\n let run = 1;\n for (let x = 1; x < size; x++) {\n if (modules[y][x] === modules[y][x - 1]) run++;\n else {\n score += runPenalty(run);\n run = 1;\n }\n }\n score += runPenalty(run);\n }\n for (let x = 0; x < size; x++) {\n let run = 1;\n for (let y = 1; y < size; y++) {\n if (modules[y][x] === modules[y - 1][x]) run++;\n else {\n score += runPenalty(run);\n run = 1;\n }\n }\n score += runPenalty(run);\n }\n\n for (let y = 0; y < size - 1; y++) {\n for (let x = 0; x < size - 1; x++) {\n const cell = modules[y][x];\n if (\n cell === modules[y][x + 1] &&\n cell === modules[y + 1][x] &&\n cell === modules[y + 1][x + 1]\n ) {\n score += 3;\n }\n }\n }\n\n // 1:1:3:1:1 with four light modules on either side — the finder's signature.\n const FINDER = [true, false, true, true, true, false, true];\n const matchesAt = (line: readonly boolean[], at: number): boolean => {\n for (let i = 0; i < FINDER.length; i++) {\n if (line[at + i] !== FINDER[i]) return false;\n }\n const before = line.slice(Math.max(0, at - 4), at);\n const after = line.slice(at + 7, at + 11);\n const clear = (part: readonly boolean[]) => part.length === 4 && part.every((m) => !m);\n return clear(before) || clear(after);\n };\n\n for (let i = 0; i < size; i++) {\n const row = modules[i];\n const column = modules.map((line) => line[i]);\n for (let at = 0; at + 7 <= size; at++) {\n if (matchesAt(row, at)) score += 40;\n if (matchesAt(column, at)) score += 40;\n }\n }\n\n let dark = 0;\n for (const row of modules) for (const cell of row) if (cell) dark++;\n const percent = (dark * 100) / (size * size);\n score += Math.floor(Math.abs(percent - 50) / 5) * 10;\n\n return score;\n}\n\nfunction cloneCanvas(canvas: Canvas): Canvas {\n return {\n size: canvas.size,\n modules: canvas.modules.map((row) => [...row]),\n reserved: canvas.reserved.map((row) => [...row]),\n };\n}\n\n/**\n * Encode text into a QR matrix.\n *\n * The whole pipeline of ISO/IEC 18004: pick the densest mode the payload\n * qualifies for, pick the smallest version that fits, build the bit stream, add\n * Reed-Solomon correction, interleave the blocks, lay the modules out, then try\n * all eight masks and keep the one the standard's penalty function likes best.\n *\n * @param text - The payload. Byte mode encodes it as UTF-8.\n * @param options - Level and an optional version floor.\n * @returns The finished matrix, without a quiet zone.\n * @throws {QRCapacityError} When the payload does not fit at that level.\n *\n * @example\n * const qr = encodeQR(\"https://tempest.dev\", { level: \"Q\" });\n * qr.modules[0][0]; // true — top-left of the finder pattern\n */\nexport function encodeQR(text: string, options: QREncodeOptions = {}): QRMatrix {\n const { level = \"M\", minVersion = MIN_VERSION } = options;\n const mode = selectMode(text);\n const version = selectVersion(text, mode, level, minVersion);\n\n const buffer = new BitBuffer();\n buffer.append(MODE_INDICATOR[mode], 4);\n buffer.append(headerCount(text, mode), charCountBits(mode, version));\n writePayload(buffer, text, mode);\n\n const capacity = dataCodewords(version, level) * 8;\n buffer.append(0, Math.min(4, capacity - buffer.length));\n buffer.append(0, (8 - (buffer.length % 8)) % 8);\n\n const data: number[] = [];\n for (let i = 0; i < buffer.length; i += 8) {\n let byte = 0;\n for (let j = 0; j < 8; j++) byte = (byte << 1) | buffer.bits[i + j];\n data.push(byte);\n }\n // The two alternating pad bytes are prescribed, not arbitrary filler.\n for (let pad = 0xec; data.length < capacity / 8; pad ^= 0xec ^ 0x11) data.push(pad);\n\n const codewords = buildCodewords(data, version, level);\n\n const base = createCanvas(version);\n drawFunctionPatterns(base, version);\n drawCodewords(base, codewords);\n\n let best: Canvas | null = null;\n let bestMask = 0;\n let bestScore = Number.POSITIVE_INFINITY;\n for (let mask = 0; mask < 8; mask++) {\n const candidate = cloneCanvas(base);\n applyMask(candidate, mask);\n drawFormatInformation(candidate, level, mask);\n const score = penalty(candidate);\n if (score < bestScore) {\n bestScore = score;\n bestMask = mask;\n best = candidate;\n }\n }\n\n const chosen = best as Canvas;\n return {\n size: chosen.size,\n modules: chosen.modules,\n version,\n level,\n mode,\n mask: bestMask,\n };\n}\n\n/**\n * The matrix as an SVG path, one `M…h…v…h…z` rectangle per dark module.\n *\n * A path beats one `<rect>` per module: a version-10 symbol is 3 481 modules,\n * and that many elements is a real cost to parse and to paint. Coordinates are\n * whole numbers in module space, so the shape stays crisp at any size.\n *\n * @param matrix - An encoded matrix.\n * @param margin - Quiet zone in modules. The standard asks for 4.\n * @returns The `d` attribute, empty when there is nothing dark.\n */\nexport function matrixToPath(matrix: QRMatrix, margin = 4): string {\n const parts: string[] = [];\n for (let y = 0; y < matrix.size; y++) {\n let runStart = -1;\n for (let x = 0; x <= matrix.size; x++) {\n const dark = x < matrix.size && matrix.modules[y][x];\n if (dark && runStart === -1) runStart = x;\n if (!dark && runStart !== -1) {\n // Merge each horizontal run into one rectangle.\n parts.push(\n `M${runStart + margin} ${y + margin}h${x - runStart}v1h-${x - runStart}z`,\n );\n runStart = -1;\n }\n }\n }\n return parts.join(\"\");\n}\n"],"mappings":"mCA4CA,IAAa,EAAb,cAAqC,KAAM,CAE1B,OACA,MAFb,YACI,EACA,EACF,CACE,MACI,cAAc,EAAO,yDAAqE,EAAM,yDAEpG,EANS,KAAA,OAAA,EACA,KAAA,MAAA,EAMT,KAAK,KAAO,iBAChB,CACJ,EAEM,EAAyC,CAAE,QAAS,EAAG,aAAc,EAAG,KAAM,CAAE,EAEhF,EAAa,WACb,EAAkB,wBAaxB,SAAgB,EAAW,EAAsB,CAG7C,OAFI,EAAW,KAAK,CAAI,EAAU,UAC9B,EAAgB,KAAK,CAAI,EAAU,eAChC,MACX,CAGA,SAAS,EAAc,EAAc,EAAyB,CAC1D,IAAM,EAAO,GAAW,EAAI,EAAI,GAAW,GAAK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IAAI,EAAsB,KACtB,EAAW,EACX,EAAY,IAChB,IAAK,IAAI,EAAO,EAAG,EAAO,EAAG,IAAQ,CACjC,IAAM,EAAY,EAAY,CAAI,EAClC,EAAU,EAAW,CAAI,EACzB,EAAsB,EAAW,EAAO,CAAI,EAC5C,IAAM,EAAQ,EAAQ,CAAS,EAC3B,EAAQ,IACR,EAAY,EACZ,EAAW,EACX,EAAO,EAEf,CAEA,IAAM,EAAS,EACf,MAAO,CACH,KAAM,EAAO,KACb,QAAS,EAAO,QAChB,UACA,QACA,OACA,KAAM,CACV,CACJ,CAaA,SAAgB,EAAa,EAAkB,EAAS,EAAW,CAC/D,IAAM,EAAkB,CAAC,EACzB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAO,KAAM,IAAK,CAClC,IAAI,EAAW,GACf,IAAK,IAAI,EAAI,EAAG,GAAK,EAAO,KAAM,IAAK,CACnC,IAAM,EAAO,EAAI,EAAO,MAAQ,EAAO,QAAQ,EAAE,CAAC,GAC9C,GAAQ,IAAa,KAAI,EAAW,GACpC,CAAC,GAAQ,IAAa,KAEtB,EAAM,KACF,IAAI,EAAW,EAAO,GAAG,EAAI,EAAO,GAAG,EAAI,EAAS,MAAM,EAAI,EAAS,EAC3E,EACA,EAAW,GAEnB,CACJ,CACA,OAAO,EAAM,KAAK,EAAE,CACxB"}
|
|
1
|
+
{"version":3,"file":"qr-encode.cjs","names":[],"sources":["../../../src/components/QRCode/qr-encode.ts"],"sourcesContent":["/**\n * @tempest-limits file-lines — ISO/IEC 18004 end to end with no dependency: mode\n * selection, the version and error-correction tables, Reed-Solomon over GF(256),\n * interleaving, the module placement with its function patterns, all eight masks and\n * the penalty scoring that picks between them. These are stages of one pipeline\n * defined by the standard; a file boundary between them would only move where the\n * reader has to look up a table.\n */\nimport {\n ALPHANUMERIC_CHARS,\n alignmentPatternPositions,\n dataCodewords,\n ECC_BLOCK_COUNT,\n ECC_CODEWORDS_PER_BLOCK,\n ECC_FORMAT_BITS,\n MAX_VERSION,\n MIN_VERSION,\n rawDataModules,\n type QRErrorCorrection,\n} from \"./qr-tables\";\n\nexport type { QRErrorCorrection };\n\n/** How the payload is packed into bits. */\nexport type QRMode = \"numeric\" | \"alphanumeric\" | \"byte\";\n\nexport interface QRMatrix {\n /** Side length in modules, including no quiet zone. */\n size: number;\n /** Row-major modules; `true` is dark. */\n modules: boolean[][];\n /** Symbol version, 1 to 40. */\n version: number;\n /** Level the symbol was encoded at. */\n level: QRErrorCorrection;\n /** The mode chosen for the payload. */\n mode: QRMode;\n /** Which of the eight masks scored best. */\n mask: number;\n}\n\nexport interface QREncodeOptions {\n /** Error correction level. Default `\"M\"`. */\n level?: QRErrorCorrection;\n /**\n * Force a minimum version. The encoder still grows past it when the payload\n * does not fit — a version is a floor, never a cap that silently truncates.\n */\n minVersion?: number;\n}\n\n/** Raised when a payload cannot be encoded at the requested level. */\nexport class QRCapacityError extends Error {\n constructor(\n readonly length: number,\n readonly level: QRErrorCorrection,\n ) {\n super(\n `Payload of ${length} bytes does not fit in a version-${MAX_VERSION} QR symbol at level ${level}. ` +\n \"Shorten the data, or drop to a lower correction level.\",\n );\n this.name = \"QRCapacityError\";\n }\n}\n\nconst MODE_INDICATOR: Record<QRMode, number> = { numeric: 1, alphanumeric: 2, byte: 4 };\n\nconst NUMERIC_RE = /^[0-9]*$/;\nconst ALPHANUMERIC_RE = /^[0-9A-Z $%*+\\-./:]*$/;\n\n/**\n * Pick the densest mode the payload qualifies for.\n *\n * Numeric packs 3 digits into 10 bits and alphanumeric 2 characters into 11, so\n * a phone number or an upper-case code encodes far smaller than the same string\n * as bytes — often a whole version smaller, which is a visibly coarser symbol\n * and therefore easier to scan.\n *\n * @param text - The payload.\n * @returns The narrowest mode that can represent it.\n */\nexport function selectMode(text: string): QRMode {\n if (NUMERIC_RE.test(text)) return \"numeric\";\n if (ALPHANUMERIC_RE.test(text)) return \"alphanumeric\";\n return \"byte\";\n}\n\n/** Bits the character-count field takes, which widens with the version. */\nfunction charCountBits(mode: QRMode, version: number): number {\n const tier = version <= 9 ? 0 : version <= 26 ? 1 : 2;\n if (mode === \"numeric\") return [10, 12, 14][tier];\n if (mode === \"alphanumeric\") return [9, 11, 13][tier];\n return [8, 16, 16][tier];\n}\n\n/** A bit sink that appends most-significant-bit first. */\nclass BitBuffer {\n readonly bits: number[] = [];\n\n append(value: number, length: number) {\n for (let i = length - 1; i >= 0; i--) this.bits.push((value >>> i) & 1);\n }\n\n get length(): number {\n return this.bits.length;\n }\n}\n\n/** UTF-8 bytes for the byte mode, so accents and emoji survive the round trip. */\nfunction utf8Bytes(text: string): number[] {\n return Array.from(new TextEncoder().encode(text));\n}\n\n/** Bits the payload itself occupies in a given mode, excluding the headers. */\nfunction payloadBits(text: string, mode: QRMode): number {\n if (mode === \"numeric\") {\n const groups = Math.floor(text.length / 3);\n const rest = text.length % 3;\n return groups * 10 + (rest === 0 ? 0 : rest === 1 ? 4 : 7);\n }\n if (mode === \"alphanumeric\") {\n return Math.floor(text.length / 2) * 11 + (text.length % 2) * 6;\n }\n return utf8Bytes(text).length * 8;\n}\n\n/** Write the payload into the buffer in the chosen mode. */\nfunction writePayload(buffer: BitBuffer, text: string, mode: QRMode) {\n if (mode === \"numeric\") {\n for (let i = 0; i < text.length; i += 3) {\n const chunk = text.slice(i, i + 3);\n buffer.append(Number(chunk), chunk.length * 3 + 1);\n }\n return;\n }\n if (mode === \"alphanumeric\") {\n for (let i = 0; i < text.length; i += 2) {\n const first = ALPHANUMERIC_CHARS.indexOf(text[i]);\n if (i + 1 === text.length) {\n buffer.append(first, 6);\n } else {\n buffer.append(first * 45 + ALPHANUMERIC_CHARS.indexOf(text[i + 1]), 11);\n }\n }\n return;\n }\n for (const byte of utf8Bytes(text)) buffer.append(byte, 8);\n}\n\n/** Character count for the header, which is bytes — not characters — in byte mode. */\nfunction headerCount(text: string, mode: QRMode): number {\n return mode === \"byte\" ? utf8Bytes(text).length : text.length;\n}\n\n/**\n * The smallest version that fits the payload at this level.\n *\n * @throws {QRCapacityError} When even version 40 is too small.\n */\nfunction selectVersion(\n text: string,\n mode: QRMode,\n level: QRErrorCorrection,\n minVersion: number,\n): number {\n const bits = payloadBits(text, mode);\n for (let version = Math.max(MIN_VERSION, minVersion); version <= MAX_VERSION; version++) {\n const capacity = dataCodewords(version, level) * 8;\n if (4 + charCountBits(mode, version) + bits <= capacity) return version;\n }\n throw new QRCapacityError(headerCount(text, mode), level);\n}\n\n// ── Reed-Solomon over GF(256), primitive polynomial 0x11D ───────────────────\n\nconst GF_EXP = new Uint8Array(512);\nconst GF_LOG = new Uint8Array(256);\n\n{\n let x = 1;\n for (let i = 0; i < 255; i++) {\n GF_EXP[i] = x;\n GF_LOG[x] = i;\n x = (x << 1) ^ (x & 0x80 ? 0x11d : 0);\n }\n for (let i = 255; i < 512; i++) GF_EXP[i] = GF_EXP[i - 255];\n}\n\nfunction gfMul(a: number, b: number): number {\n if (a === 0 || b === 0) return 0;\n return GF_EXP[GF_LOG[a] + GF_LOG[b]];\n}\n\n/** The generator polynomial for `degree` error-correction codewords. */\nfunction rsGenerator(degree: number): number[] {\n let poly = [1];\n for (let i = 0; i < degree; i++) {\n const next = new Array<number>(poly.length + 1).fill(0);\n for (let j = 0; j < poly.length; j++) {\n next[j] ^= poly[j];\n next[j + 1] ^= gfMul(poly[j], GF_EXP[i]);\n }\n poly = next;\n }\n return poly;\n}\n\n/**\n * The error-correction codewords for one block.\n *\n * @param data - The block's data codewords.\n * @param degree - How many correction codewords to produce.\n * @returns The remainder of the polynomial division, which is the ECC block.\n */\nexport function reedSolomon(data: readonly number[], degree: number): number[] {\n const generator = rsGenerator(degree);\n const remainder = new Array<number>(degree).fill(0);\n for (const byte of data) {\n const factor = byte ^ remainder[0];\n remainder.shift();\n remainder.push(0);\n for (let i = 0; i < degree; i++) {\n remainder[i] ^= gfMul(generator[i + 1], factor);\n }\n }\n return remainder;\n}\n\n/**\n * Split into blocks, add correction, and interleave into the final codeword\n * stream.\n *\n * Interleaving is what makes the correction useful against a real-world smudge:\n * a contiguous scratch on the printed symbol then damages a few codewords of\n * every block instead of destroying one block completely.\n */\nfunction buildCodewords(\n data: readonly number[],\n version: number,\n level: QRErrorCorrection,\n): number[] {\n const blockCount = ECC_BLOCK_COUNT[level][version - 1];\n const eccPerBlock = ECC_CODEWORDS_PER_BLOCK[level][version - 1];\n const totalCodewords = Math.floor(rawDataModules(version) / 8);\n const shortBlockLength = Math.floor(totalCodewords / blockCount) - eccPerBlock;\n const longBlockCount = totalCodewords % blockCount;\n\n const dataBlocks: number[][] = [];\n const eccBlocks: number[][] = [];\n let offset = 0;\n for (let i = 0; i < blockCount; i++) {\n const length = shortBlockLength + (i >= blockCount - longBlockCount ? 1 : 0);\n const block = data.slice(offset, offset + length);\n offset += length;\n dataBlocks.push(block);\n eccBlocks.push(reedSolomon(block, eccPerBlock));\n }\n\n const result: number[] = [];\n for (let i = 0; i < shortBlockLength + 1; i++) {\n for (const block of dataBlocks) {\n if (i < block.length) result.push(block[i]);\n }\n }\n for (let i = 0; i < eccPerBlock; i++) {\n for (const block of eccBlocks) result.push(block[i]);\n }\n return result;\n}\n\n// ── Matrix construction ─────────────────────────────────────────────────────\n\n/** A grid under construction: modules plus which cells are function patterns. */\ninterface Canvas {\n size: number;\n modules: boolean[][];\n reserved: boolean[][];\n}\n\nfunction createCanvas(version: number): Canvas {\n const size = version * 4 + 17;\n return {\n size,\n modules: Array.from({ length: size }, () => new Array<boolean>(size).fill(false)),\n reserved: Array.from({ length: size }, () => new Array<boolean>(size).fill(false)),\n };\n}\n\nfunction setModule(canvas: Canvas, x: number, y: number, dark: boolean, reserve = true) {\n if (x < 0 || y < 0 || x >= canvas.size || y >= canvas.size) return;\n canvas.modules[y][x] = dark;\n if (reserve) canvas.reserved[y][x] = true;\n}\n\n/** A finder pattern with its separator, anchored at a corner. */\nfunction drawFinder(canvas: Canvas, left: number, top: number) {\n for (let dy = -1; dy <= 7; dy++) {\n for (let dx = -1; dx <= 7; dx++) {\n const distance = Math.max(Math.abs(dx - 3), Math.abs(dy - 3));\n setModule(canvas, left + dx, top + dy, distance !== 2 && distance <= 3);\n }\n }\n}\n\nfunction drawAlignment(canvas: Canvas, cx: number, cy: number) {\n for (let dy = -2; dy <= 2; dy++) {\n for (let dx = -2; dx <= 2; dx++) {\n setModule(canvas, cx + dx, cy + dy, Math.max(Math.abs(dx), Math.abs(dy)) !== 1);\n }\n }\n}\n\nfunction drawFunctionPatterns(canvas: Canvas, version: number) {\n drawFinder(canvas, 0, 0);\n drawFinder(canvas, canvas.size - 7, 0);\n drawFinder(canvas, 0, canvas.size - 7);\n\n for (let i = 8; i < canvas.size - 8; i++) {\n const dark = i % 2 === 0;\n setModule(canvas, i, 6, dark);\n setModule(canvas, 6, i, dark);\n }\n\n const positions = alignmentPatternPositions(version);\n for (const cy of positions) {\n for (const cx of positions) {\n // The three corners already hold finder patterns.\n const atFinder =\n (cx === 6 && cy === 6) ||\n (cx === 6 && cy === canvas.size - 7) ||\n (cx === canvas.size - 7 && cy === 6);\n if (!atFinder) drawAlignment(canvas, cx, cy);\n }\n }\n\n // Reserve the format information, and light the always-dark module.\n for (let i = 0; i < 9; i++) {\n setModule(canvas, i, 8, false);\n setModule(canvas, 8, i, false);\n }\n for (let i = 0; i < 8; i++) {\n setModule(canvas, canvas.size - 1 - i, 8, false);\n setModule(canvas, 8, canvas.size - 1 - i, false);\n }\n setModule(canvas, 8, canvas.size - 8, true);\n\n if (version >= 7) {\n const value = versionInformation(version);\n for (let i = 0; i < 18; i++) {\n const bit = ((value >>> i) & 1) === 1;\n const a = canvas.size - 11 + (i % 3);\n const b = Math.floor(i / 3);\n setModule(canvas, a, b, bit);\n setModule(canvas, b, a, bit);\n }\n }\n}\n\n/** The 18-bit version information block, BCH(18,6) with generator 0x1F25. */\nfunction versionInformation(version: number): number {\n let remainder = version;\n for (let i = 0; i < 12; i++) {\n remainder = (remainder << 1) ^ ((remainder >>> 11) * 0x1f25);\n }\n return (version << 12) | remainder;\n}\n\n/** The 15-bit format information, BCH(15,5) masked with 0x5412. */\nfunction formatInformation(level: QRErrorCorrection, mask: number): number {\n const data = (ECC_FORMAT_BITS[level] << 3) | mask;\n let remainder = data;\n for (let i = 0; i < 10; i++) {\n remainder = (remainder << 1) ^ ((remainder >>> 9) * 0x537);\n }\n return ((data << 10) | remainder) ^ 0x5412;\n}\n\nfunction drawFormatInformation(canvas: Canvas, level: QRErrorCorrection, mask: number) {\n const bits = formatInformation(level, mask);\n\n for (let i = 0; i <= 5; i++) setModule(canvas, 8, i, ((bits >>> i) & 1) === 1);\n setModule(canvas, 8, 7, ((bits >>> 6) & 1) === 1);\n setModule(canvas, 8, 8, ((bits >>> 7) & 1) === 1);\n setModule(canvas, 7, 8, ((bits >>> 8) & 1) === 1);\n for (let i = 9; i < 15; i++) setModule(canvas, 14 - i, 8, ((bits >>> i) & 1) === 1);\n\n for (let i = 0; i < 8; i++) {\n setModule(canvas, canvas.size - 1 - i, 8, ((bits >>> i) & 1) === 1);\n }\n for (let i = 8; i < 15; i++) {\n setModule(canvas, 8, canvas.size - 15 + i, ((bits >>> i) & 1) === 1);\n }\n setModule(canvas, 8, canvas.size - 8, true);\n}\n\n/**\n * Lay the codeword stream into the free modules.\n *\n * The path is a boustrophedon over two-module columns from the bottom-right\n * corner, skipping the vertical timing pattern in column 6 entirely — that\n * column would otherwise shift every subsequent column by one.\n */\nfunction drawCodewords(canvas: Canvas, codewords: readonly number[]) {\n let bitIndex = 0;\n let upward = true;\n\n for (let right = canvas.size - 1; right >= 1; right -= 2) {\n if (right === 6) right = 5;\n for (let step = 0; step < canvas.size; step++) {\n const y = upward ? canvas.size - 1 - step : step;\n for (let column = 0; column < 2; column++) {\n const x = right - column;\n if (canvas.reserved[y][x]) continue;\n const byte = codewords[bitIndex >>> 3];\n // Remainder bits past the stream are light, per the standard.\n canvas.modules[y][x] =\n byte !== undefined && ((byte >>> (7 - (bitIndex & 7))) & 1) === 1;\n bitIndex++;\n }\n }\n upward = !upward;\n }\n}\n\nconst MASK_FUNCTIONS: readonly ((x: number, y: number) => boolean)[] = [\n (x, y) => (x + y) % 2 === 0,\n (_x, y) => y % 2 === 0,\n (x) => x % 3 === 0,\n (x, y) => (x + y) % 3 === 0,\n (x, y) => (Math.floor(y / 2) + Math.floor(x / 3)) % 2 === 0,\n (x, y) => ((x * y) % 2) + ((x * y) % 3) === 0,\n (x, y) => (((x * y) % 2) + ((x * y) % 3)) % 2 === 0,\n (x, y) => (((x + y) % 2) + ((x * y) % 3)) % 2 === 0,\n];\n\nfunction applyMask(canvas: Canvas, mask: number) {\n const fn = MASK_FUNCTIONS[mask];\n for (let y = 0; y < canvas.size; y++) {\n for (let x = 0; x < canvas.size; x++) {\n if (!canvas.reserved[y][x] && fn(x, y)) canvas.modules[y][x] = !canvas.modules[y][x];\n }\n }\n}\n\n/**\n * Score a masked symbol; lower is better.\n *\n * The four penalties push away from patterns a scanner confuses with the finder\n * marks, and from large flat areas where it cannot lock on.\n */\nfunction penalty(canvas: Canvas): number {\n const { size, modules } = canvas;\n let score = 0;\n\n const runPenalty = (run: number) => (run >= 5 ? 3 + (run - 5) : 0);\n\n for (let y = 0; y < size; y++) {\n let run = 1;\n for (let x = 1; x < size; x++) {\n if (modules[y][x] === modules[y][x - 1]) run++;\n else {\n score += runPenalty(run);\n run = 1;\n }\n }\n score += runPenalty(run);\n }\n for (let x = 0; x < size; x++) {\n let run = 1;\n for (let y = 1; y < size; y++) {\n if (modules[y][x] === modules[y - 1][x]) run++;\n else {\n score += runPenalty(run);\n run = 1;\n }\n }\n score += runPenalty(run);\n }\n\n for (let y = 0; y < size - 1; y++) {\n for (let x = 0; x < size - 1; x++) {\n const cell = modules[y][x];\n if (\n cell === modules[y][x + 1] &&\n cell === modules[y + 1][x] &&\n cell === modules[y + 1][x + 1]\n ) {\n score += 3;\n }\n }\n }\n\n // 1:1:3:1:1 with four light modules on either side — the finder's signature.\n const FINDER = [true, false, true, true, true, false, true];\n const matchesAt = (line: readonly boolean[], at: number): boolean => {\n for (let i = 0; i < FINDER.length; i++) {\n if (line[at + i] !== FINDER[i]) return false;\n }\n const before = line.slice(Math.max(0, at - 4), at);\n const after = line.slice(at + 7, at + 11);\n const clear = (part: readonly boolean[]) => part.length === 4 && part.every((m) => !m);\n return clear(before) || clear(after);\n };\n\n for (let i = 0; i < size; i++) {\n const row = modules[i];\n const column = modules.map((line) => line[i]);\n for (let at = 0; at + 7 <= size; at++) {\n if (matchesAt(row, at)) score += 40;\n if (matchesAt(column, at)) score += 40;\n }\n }\n\n let dark = 0;\n for (const row of modules) for (const cell of row) if (cell) dark++;\n const percent = (dark * 100) / (size * size);\n score += Math.floor(Math.abs(percent - 50) / 5) * 10;\n\n return score;\n}\n\nfunction cloneCanvas(canvas: Canvas): Canvas {\n return {\n size: canvas.size,\n modules: canvas.modules.map((row) => [...row]),\n reserved: canvas.reserved.map((row) => [...row]),\n };\n}\n\n/**\n * Encode text into a QR matrix.\n *\n * The whole pipeline of ISO/IEC 18004: pick the densest mode the payload\n * qualifies for, pick the smallest version that fits, build the bit stream, add\n * Reed-Solomon correction, interleave the blocks, lay the modules out, then try\n * all eight masks and keep the one the standard's penalty function likes best.\n *\n * @param text - The payload. Byte mode encodes it as UTF-8.\n * @param options - Level and an optional version floor.\n * @returns The finished matrix, without a quiet zone.\n * @throws {QRCapacityError} When the payload does not fit at that level.\n *\n * @example\n * const qr = encodeQR(\"https://tempest.dev\", { level: \"Q\" });\n * qr.modules[0][0]; // true — top-left of the finder pattern\n */\nexport function encodeQR(text: string, options: QREncodeOptions = {}): QRMatrix {\n const { level = \"M\", minVersion = MIN_VERSION } = options;\n const mode = selectMode(text);\n const version = selectVersion(text, mode, level, minVersion);\n\n const buffer = new BitBuffer();\n buffer.append(MODE_INDICATOR[mode], 4);\n buffer.append(headerCount(text, mode), charCountBits(mode, version));\n writePayload(buffer, text, mode);\n\n const capacity = dataCodewords(version, level) * 8;\n buffer.append(0, Math.min(4, capacity - buffer.length));\n buffer.append(0, (8 - (buffer.length % 8)) % 8);\n\n const data: number[] = [];\n for (let i = 0; i < buffer.length; i += 8) {\n let byte = 0;\n for (let j = 0; j < 8; j++) byte = (byte << 1) | buffer.bits[i + j];\n data.push(byte);\n }\n // The two alternating pad bytes are prescribed, not arbitrary filler.\n for (let pad = 0xec; data.length < capacity / 8; pad ^= 0xec ^ 0x11) data.push(pad);\n\n const codewords = buildCodewords(data, version, level);\n\n const base = createCanvas(version);\n drawFunctionPatterns(base, version);\n drawCodewords(base, codewords);\n\n let best: Canvas | null = null;\n let bestMask = 0;\n let bestScore = Number.POSITIVE_INFINITY;\n for (let mask = 0; mask < 8; mask++) {\n const candidate = cloneCanvas(base);\n applyMask(candidate, mask);\n drawFormatInformation(candidate, level, mask);\n const score = penalty(candidate);\n if (score < bestScore) {\n bestScore = score;\n bestMask = mask;\n best = candidate;\n }\n }\n\n const chosen = best as Canvas;\n return {\n size: chosen.size,\n modules: chosen.modules,\n version,\n level,\n mode,\n mask: bestMask,\n };\n}\n\n/**\n * The matrix as an SVG path, one `M…h…v…h…z` rectangle per dark module.\n *\n * A path beats one `<rect>` per module: a version-10 symbol is 3 481 modules,\n * and that many elements is a real cost to parse and to paint. Coordinates are\n * whole numbers in module space, so the shape stays crisp at any size.\n *\n * @param matrix - An encoded matrix.\n * @param margin - Quiet zone in modules. The standard asks for 4.\n * @returns The `d` attribute, empty when there is nothing dark.\n */\nexport function matrixToPath(matrix: QRMatrix, margin = 4): string {\n const parts: string[] = [];\n for (let y = 0; y < matrix.size; y++) {\n let runStart = -1;\n for (let x = 0; x <= matrix.size; x++) {\n const dark = x < matrix.size && matrix.modules[y][x];\n if (dark && runStart === -1) runStart = x;\n if (!dark && runStart !== -1) {\n // Merge each horizontal run into one rectangle.\n parts.push(\n `M${runStart + margin} ${y + margin}h${x - runStart}v1h-${x - runStart}z`,\n );\n runStart = -1;\n }\n }\n }\n return parts.join(\"\");\n}\n"],"mappings":"mCAoDA,IAAa,EAAb,cAAqC,KAAM,CAE1B,OACA,MAFb,YACI,E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