tempest-react-sdk 0.26.1 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -1
- package/bin/lib/css/analyze.mjs +149 -0
- package/bin/lib/css/analyze.test.mjs +136 -0
- package/bin/lib/css/collect.mjs +152 -0
- package/bin/lib/css/findings.mjs +79 -0
- package/bin/lib/css/fix.e2e.test.mjs +99 -0
- package/bin/lib/css/fix.mjs +138 -0
- package/bin/lib/css/fix.test.mjs +108 -0
- package/bin/lib/css/index.mjs +16 -0
- package/bin/lib/css/parse.mjs +398 -0
- package/bin/lib/css/parse.test.mjs +146 -0
- package/bin/lib/css/properties.mjs +399 -0
- package/bin/lib/css/repetition.mjs +213 -0
- package/bin/lib/css/repetition.test.mjs +166 -0
- package/bin/lib/css/semantic.mjs +327 -0
- package/bin/lib/css/semantic.test.mjs +201 -0
- package/bin/lib/css/tokens.mjs +119 -0
- package/bin/lib/doctor/doctor.e2e.test.mjs +246 -0
- package/bin/tempest.mjs +272 -36
- package/dist/charts/scales.cjs +2 -0
- package/dist/charts/scales.cjs.map +1 -0
- package/dist/charts/scales.js +29 -0
- package/dist/charts/scales.js.map +1 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.d.ts +91 -0
- package/dist/charts.js +9 -8
- package/dist/components/BottomNavigation/BottomNavigation.module.cjs.map +1 -1
- package/dist/components/BottomNavigation/BottomNavigation.module.js.map +1 -1
- package/dist/components/Carousel/Carousel.module.cjs.map +1 -1
- package/dist/components/Carousel/Carousel.module.js.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.cjs +3 -0
- package/dist/components/CodeBlock/CodeBlock.cjs.map +1 -0
- package/dist/components/CodeBlock/CodeBlock.js +53 -0
- package/dist/components/CodeBlock/CodeBlock.js.map +1 -0
- package/dist/components/CodeBlock/CodeBlock.module.cjs +2 -0
- package/dist/components/CodeBlock/CodeBlock.module.cjs.map +1 -0
- package/dist/components/CodeBlock/CodeBlock.module.js +29 -0
- package/dist/components/CodeBlock/CodeBlock.module.js.map +1 -0
- package/dist/components/CodeBlock/tokenize.cjs +3 -0
- package/dist/components/CodeBlock/tokenize.cjs.map +1 -0
- package/dist/components/CodeBlock/tokenize.js +267 -0
- package/dist/components/CodeBlock/tokenize.js.map +1 -0
- package/dist/components/ImageCropper/ImageCropper.cjs +2 -0
- package/dist/components/ImageCropper/ImageCropper.cjs.map +1 -0
- package/dist/components/ImageCropper/ImageCropper.js +240 -0
- package/dist/components/ImageCropper/ImageCropper.js.map +1 -0
- package/dist/components/ImageCropper/ImageCropper.module.cjs +2 -0
- package/dist/components/ImageCropper/ImageCropper.module.cjs.map +1 -0
- package/dist/components/ImageCropper/ImageCropper.module.js +15 -0
- package/dist/components/ImageCropper/ImageCropper.module.js.map +1 -0
- package/dist/components/ImageCropper/crop-geometry.cjs +2 -0
- package/dist/components/ImageCropper/crop-geometry.cjs.map +1 -0
- package/dist/components/ImageCropper/crop-geometry.js +52 -0
- package/dist/components/ImageCropper/crop-geometry.js.map +1 -0
- package/dist/components/Navbar/Navbar.module.cjs.map +1 -1
- package/dist/components/Navbar/Navbar.module.js.map +1 -1
- package/dist/components/QRCode/QRCode.cjs +2 -0
- package/dist/components/QRCode/QRCode.cjs.map +1 -0
- package/dist/components/QRCode/QRCode.js +49 -0
- package/dist/components/QRCode/QRCode.js.map +1 -0
- package/dist/components/QRCode/QRCode.module.cjs +2 -0
- package/dist/components/QRCode/QRCode.module.cjs.map +1 -0
- package/dist/components/QRCode/QRCode.module.js +9 -0
- package/dist/components/QRCode/QRCode.module.js.map +1 -0
- package/dist/components/QRCode/qr-encode.cjs +2 -0
- package/dist/components/QRCode/qr-encode.cjs.map +1 -0
- package/dist/components/QRCode/qr-encode.js +295 -0
- package/dist/components/QRCode/qr-encode.js.map +1 -0
- package/dist/components/QRCode/qr-tables.cjs +2 -0
- package/dist/components/QRCode/qr-tables.cjs.map +1 -0
- package/dist/components/QRCode/qr-tables.js +366 -0
- package/dist/components/QRCode/qr-tables.js.map +1 -0
- package/dist/components/Scheduler/Scheduler.cjs +2 -0
- package/dist/components/Scheduler/Scheduler.cjs.map +1 -0
- package/dist/components/Scheduler/Scheduler.js +134 -0
- package/dist/components/Scheduler/Scheduler.js.map +1 -0
- package/dist/components/Scheduler/Scheduler.module.cjs +2 -0
- package/dist/components/Scheduler/Scheduler.module.cjs.map +1 -0
- package/dist/components/Scheduler/Scheduler.module.js +26 -0
- package/dist/components/Scheduler/Scheduler.module.js.map +1 -0
- package/dist/components/Scheduler/scheduler-layout.cjs +2 -0
- package/dist/components/Scheduler/scheduler-layout.cjs.map +1 -0
- package/dist/components/Scheduler/scheduler-layout.js +97 -0
- package/dist/components/Scheduler/scheduler-layout.js.map +1 -0
- package/dist/components/ScrollArea/ScrollArea.cjs +1 -1
- package/dist/components/ScrollArea/ScrollArea.cjs.map +1 -1
- package/dist/components/ScrollArea/ScrollArea.js +22 -16
- package/dist/components/ScrollArea/ScrollArea.js.map +1 -1
- package/dist/components/ScrollArea/ScrollArea.module.cjs.map +1 -1
- package/dist/components/ScrollArea/ScrollArea.module.js.map +1 -1
- package/dist/components/Sparkline/Sparkline.cjs +2 -0
- package/dist/components/Sparkline/Sparkline.cjs.map +1 -0
- package/dist/components/Sparkline/Sparkline.js +64 -0
- package/dist/components/Sparkline/Sparkline.js.map +1 -0
- package/dist/components/Sparkline/Sparkline.module.cjs +2 -0
- package/dist/components/Sparkline/Sparkline.module.cjs.map +1 -0
- package/dist/components/Sparkline/Sparkline.module.js +10 -0
- package/dist/components/Sparkline/Sparkline.module.js.map +1 -0
- package/dist/components/Sparkline/sparkline-geometry.cjs +2 -0
- package/dist/components/Sparkline/sparkline-geometry.cjs.map +1 -0
- package/dist/components/Sparkline/sparkline-geometry.js +56 -0
- package/dist/components/Sparkline/sparkline-geometry.js.map +1 -0
- package/dist/components/Table/Table.cjs +1 -1
- package/dist/components/Table/Table.cjs.map +1 -1
- package/dist/components/Table/Table.js +37 -30
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/Table/Table.module.cjs.map +1 -1
- package/dist/components/Table/Table.module.js.map +1 -1
- package/dist/components/VirtualList/VirtualList.cjs +1 -1
- package/dist/components/VirtualList/VirtualList.cjs.map +1 -1
- package/dist/components/VirtualList/VirtualList.js +13 -11
- package/dist/components/VirtualList/VirtualList.js.map +1 -1
- package/dist/components/VirtualList/VirtualList.module.cjs.map +1 -1
- package/dist/components/VirtualList/VirtualList.module.js.map +1 -1
- package/dist/hooks/use-scroll-overflow.cjs +2 -0
- package/dist/hooks/use-scroll-overflow.cjs.map +1 -0
- package/dist/hooks/use-scroll-overflow.js +22 -0
- package/dist/hooks/use-scroll-overflow.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/tempest-react-sdk.cjs +1 -1
- package/dist/tempest-react-sdk.d.ts +607 -2
- package/dist/tempest-react-sdk.js +197 -188
- package/dist/theme/create-theme.cjs +3 -3
- package/dist/theme/create-theme.cjs.map +1 -1
- package/dist/theme/create-theme.js +52 -28
- package/dist/theme/create-theme.js.map +1 -1
- package/dist/theme/data-viz-ramps.cjs +2 -0
- package/dist/theme/data-viz-ramps.cjs.map +1 -0
- package/dist/theme/data-viz-ramps.js +58 -0
- package/dist/theme/data-viz-ramps.js.map +1 -0
- package/package.json +2 -1
- package/template/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qr-encode.js","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":";;AA4CA,IAAa,IAAb,cAAqC,MAAM;CAE1B;CACA;CAFb,YACI,GACA,GACF;EAKE,AAJA,MACI,cAAc,EAAO,yDAAqE,EAAM,yDAEpG,GANS,KAAA,SAAA,GACA,KAAA,QAAA,GAMT,KAAK,OAAO;CAChB;AACJ,GAEM,IAAyC;CAAE,SAAS;CAAG,cAAc;CAAG,MAAM;AAAE,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18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],M:[10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],Q:[13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],H:[17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]},n={L:[1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],M:[1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],Q:[1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],H:[1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]},r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;function i(e){let t=(16*e+128)*e+64;if(e>=2){let n=Math.floor(e/7)+2;t-=(25*n-10)*n-55,e>=7&&(t-=36)}return t}function a(e,r){return Math.floor(i(e)/8)-t[r][e-1]*n[r][e-1]}function o(e){if(e===1)return[];let t=Math.floor(e/7)+2,n=e===32?26:Math.ceil((e*4+4)/(t*2-2))*2,r=[6];for(let i=e*4+10;r.length<t;i-=n)r.splice(1,0,i);return r}exports.ALPHANUMERIC_CHARS=r,exports.ECC_BLOCK_COUNT=n,exports.ECC_CODEWORDS_PER_BLOCK=t,exports.ECC_FORMAT_BITS=e,exports.alignmentPatternPositions=o,exports.dataCodewords=a,exports.rawDataModules=i;
|
|
2
|
+
//# sourceMappingURL=qr-tables.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qr-tables.cjs","names":[],"sources":["../../../src/components/QRCode/qr-tables.ts"],"sourcesContent":["/**\n * The fixed tables of ISO/IEC 18004, transcribed.\n *\n * They are data, not logic: the standard specifies them and there is nothing to\n * derive. They live apart from {@link ./qr-encode} so the algorithm reads as\n * algorithm and a typo in a table stays findable.\n */\n\n/** Error correction level, by how much of the symbol it can lose and survive. */\nexport type QRErrorCorrection = \"L\" | \"M\" | \"Q\" | \"H\";\n\nexport const ECC_LEVELS: readonly QRErrorCorrection[] = [\"L\", \"M\", \"Q\", \"H\"];\n\n/** The 2-bit code each level carries in the format information. */\nexport const ECC_FORMAT_BITS: Record<QRErrorCorrection, number> = { L: 1, M: 0, Q: 3, H: 2 };\n\n/**\n * Error-correction codewords per block, indexed `[level][version - 1]`.\n *\n * Together with {@link ECC_BLOCK_COUNT} this fixes how much of each version is\n * data and how much is redundancy.\n */\nexport const ECC_CODEWORDS_PER_BLOCK: Record<QRErrorCorrection, readonly number[]> = {\n L: [\n 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30,\n 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,\n ],\n M: [\n 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28,\n 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,\n ],\n Q: [\n 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30,\n 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,\n ],\n H: [\n 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30,\n 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,\n ],\n};\n\n/** Number of error-correction blocks, indexed `[level][version - 1]`. */\nexport const ECC_BLOCK_COUNT: Record<QRErrorCorrection, readonly number[]> = {\n L: [\n 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14,\n 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25,\n ],\n M: [\n 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23,\n 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49,\n ],\n Q: [\n 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34,\n 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68,\n ],\n H: [\n 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35,\n 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81,\n ],\n};\n\n/** The alphanumeric mode's 45-character alphabet, in code order. */\nexport const ALPHANUMERIC_CHARS = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:\";\n\n/** Lowest and highest symbol version. */\nexport const MIN_VERSION = 1;\nexport const MAX_VERSION = 40;\n\n/**\n * Total data modules in a symbol, before subtracting error correction.\n *\n * Closed form rather than a 40-row table: the function patterns a version\n * carries are themselves a function of the version, so counting them beats\n * transcribing the totals and hoping.\n *\n * @param version - Symbol version, 1 to 40.\n * @returns The module count available to data and error correction.\n */\nexport function rawDataModules(version: number): number {\n let result = (16 * version + 128) * version + 64;\n if (version >= 2) {\n const alignCount = Math.floor(version / 7) + 2;\n result -= (25 * alignCount - 10) * alignCount - 55;\n if (version >= 7) result -= 36;\n }\n return result;\n}\n\n/**\n * How many data codewords a version holds at a given level.\n *\n * @param version - Symbol version, 1 to 40.\n * @param level - Error correction level.\n * @returns Codewords left for the message itself.\n */\nexport function dataCodewords(version: number, level: QRErrorCorrection): number {\n return (\n Math.floor(rawDataModules(version) / 8) -\n ECC_CODEWORDS_PER_BLOCK[level][version - 1] * ECC_BLOCK_COUNT[level][version - 1]\n );\n}\n\n/**\n * Row/column centres of the alignment patterns for a version.\n *\n * @param version - Symbol version, 1 to 40.\n * @returns Coordinates, ascending. Empty for version 1, which has none.\n */\nexport function alignmentPatternPositions(version: number): number[] {\n if (version === 1) return [];\n const count = Math.floor(version / 7) + 2;\n // Version 32 is the one case the general spacing rule gets wrong.\n const step = version === 32 ? 26 : Math.ceil((version * 4 + 4) / (count * 2 - 2)) * 2;\n const positions = [6];\n for (let pos = version * 4 + 10; positions.length < count; pos -= step) {\n positions.splice(1, 0, pos);\n }\n return positions;\n}\n"],"mappings":"AAcA,IAAa,EAAqD,CAAE,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,CAAE,EAQ9E,EAAwE,CACjF,EAAG,CACC,EAAG,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GACvF,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,EACpE,EACA,EAAG,CACC,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GACxF,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,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
+
L: 1,
|
|
4
|
+
M: 0,
|
|
5
|
+
Q: 3,
|
|
6
|
+
H: 2
|
|
7
|
+
}, t = {
|
|
8
|
+
L: [
|
|
9
|
+
7,
|
|
10
|
+
10,
|
|
11
|
+
15,
|
|
12
|
+
20,
|
|
13
|
+
26,
|
|
14
|
+
18,
|
|
15
|
+
20,
|
|
16
|
+
24,
|
|
17
|
+
30,
|
|
18
|
+
18,
|
|
19
|
+
20,
|
|
20
|
+
24,
|
|
21
|
+
26,
|
|
22
|
+
30,
|
|
23
|
+
22,
|
|
24
|
+
24,
|
|
25
|
+
28,
|
|
26
|
+
30,
|
|
27
|
+
28,
|
|
28
|
+
28,
|
|
29
|
+
28,
|
|
30
|
+
28,
|
|
31
|
+
30,
|
|
32
|
+
30,
|
|
33
|
+
26,
|
|
34
|
+
28,
|
|
35
|
+
30,
|
|
36
|
+
30,
|
|
37
|
+
30,
|
|
38
|
+
30,
|
|
39
|
+
30,
|
|
40
|
+
30,
|
|
41
|
+
30,
|
|
42
|
+
30,
|
|
43
|
+
30,
|
|
44
|
+
30,
|
|
45
|
+
30,
|
|
46
|
+
30,
|
|
47
|
+
30,
|
|
48
|
+
30
|
|
49
|
+
],
|
|
50
|
+
M: [
|
|
51
|
+
10,
|
|
52
|
+
16,
|
|
53
|
+
26,
|
|
54
|
+
18,
|
|
55
|
+
24,
|
|
56
|
+
16,
|
|
57
|
+
18,
|
|
58
|
+
22,
|
|
59
|
+
22,
|
|
60
|
+
26,
|
|
61
|
+
30,
|
|
62
|
+
22,
|
|
63
|
+
22,
|
|
64
|
+
24,
|
|
65
|
+
24,
|
|
66
|
+
28,
|
|
67
|
+
28,
|
|
68
|
+
26,
|
|
69
|
+
26,
|
|
70
|
+
26,
|
|
71
|
+
26,
|
|
72
|
+
28,
|
|
73
|
+
28,
|
|
74
|
+
28,
|
|
75
|
+
28,
|
|
76
|
+
28,
|
|
77
|
+
28,
|
|
78
|
+
28,
|
|
79
|
+
28,
|
|
80
|
+
28,
|
|
81
|
+
28,
|
|
82
|
+
28,
|
|
83
|
+
28,
|
|
84
|
+
28,
|
|
85
|
+
28,
|
|
86
|
+
28,
|
|
87
|
+
28,
|
|
88
|
+
28,
|
|
89
|
+
28,
|
|
90
|
+
28
|
|
91
|
+
],
|
|
92
|
+
Q: [
|
|
93
|
+
13,
|
|
94
|
+
22,
|
|
95
|
+
18,
|
|
96
|
+
26,
|
|
97
|
+
18,
|
|
98
|
+
24,
|
|
99
|
+
18,
|
|
100
|
+
22,
|
|
101
|
+
20,
|
|
102
|
+
24,
|
|
103
|
+
28,
|
|
104
|
+
26,
|
|
105
|
+
24,
|
|
106
|
+
20,
|
|
107
|
+
30,
|
|
108
|
+
24,
|
|
109
|
+
28,
|
|
110
|
+
28,
|
|
111
|
+
26,
|
|
112
|
+
30,
|
|
113
|
+
28,
|
|
114
|
+
30,
|
|
115
|
+
30,
|
|
116
|
+
30,
|
|
117
|
+
30,
|
|
118
|
+
28,
|
|
119
|
+
30,
|
|
120
|
+
30,
|
|
121
|
+
30,
|
|
122
|
+
30,
|
|
123
|
+
30,
|
|
124
|
+
30,
|
|
125
|
+
30,
|
|
126
|
+
30,
|
|
127
|
+
30,
|
|
128
|
+
30,
|
|
129
|
+
30,
|
|
130
|
+
30,
|
|
131
|
+
30,
|
|
132
|
+
30
|
|
133
|
+
],
|
|
134
|
+
H: [
|
|
135
|
+
17,
|
|
136
|
+
28,
|
|
137
|
+
22,
|
|
138
|
+
16,
|
|
139
|
+
22,
|
|
140
|
+
28,
|
|
141
|
+
26,
|
|
142
|
+
26,
|
|
143
|
+
24,
|
|
144
|
+
28,
|
|
145
|
+
24,
|
|
146
|
+
28,
|
|
147
|
+
22,
|
|
148
|
+
24,
|
|
149
|
+
24,
|
|
150
|
+
30,
|
|
151
|
+
28,
|
|
152
|
+
28,
|
|
153
|
+
26,
|
|
154
|
+
28,
|
|
155
|
+
30,
|
|
156
|
+
24,
|
|
157
|
+
30,
|
|
158
|
+
30,
|
|
159
|
+
30,
|
|
160
|
+
30,
|
|
161
|
+
30,
|
|
162
|
+
30,
|
|
163
|
+
30,
|
|
164
|
+
30,
|
|
165
|
+
30,
|
|
166
|
+
30,
|
|
167
|
+
30,
|
|
168
|
+
30,
|
|
169
|
+
30,
|
|
170
|
+
30,
|
|
171
|
+
30,
|
|
172
|
+
30,
|
|
173
|
+
30,
|
|
174
|
+
30
|
|
175
|
+
]
|
|
176
|
+
}, n = {
|
|
177
|
+
L: [
|
|
178
|
+
1,
|
|
179
|
+
1,
|
|
180
|
+
1,
|
|
181
|
+
1,
|
|
182
|
+
1,
|
|
183
|
+
2,
|
|
184
|
+
2,
|
|
185
|
+
2,
|
|
186
|
+
2,
|
|
187
|
+
4,
|
|
188
|
+
4,
|
|
189
|
+
4,
|
|
190
|
+
4,
|
|
191
|
+
4,
|
|
192
|
+
6,
|
|
193
|
+
6,
|
|
194
|
+
6,
|
|
195
|
+
6,
|
|
196
|
+
7,
|
|
197
|
+
8,
|
|
198
|
+
8,
|
|
199
|
+
9,
|
|
200
|
+
9,
|
|
201
|
+
10,
|
|
202
|
+
12,
|
|
203
|
+
12,
|
|
204
|
+
12,
|
|
205
|
+
13,
|
|
206
|
+
14,
|
|
207
|
+
15,
|
|
208
|
+
16,
|
|
209
|
+
17,
|
|
210
|
+
18,
|
|
211
|
+
19,
|
|
212
|
+
19,
|
|
213
|
+
20,
|
|
214
|
+
21,
|
|
215
|
+
22,
|
|
216
|
+
24,
|
|
217
|
+
25
|
|
218
|
+
],
|
|
219
|
+
M: [
|
|
220
|
+
1,
|
|
221
|
+
1,
|
|
222
|
+
1,
|
|
223
|
+
2,
|
|
224
|
+
2,
|
|
225
|
+
4,
|
|
226
|
+
4,
|
|
227
|
+
4,
|
|
228
|
+
5,
|
|
229
|
+
5,
|
|
230
|
+
5,
|
|
231
|
+
8,
|
|
232
|
+
9,
|
|
233
|
+
9,
|
|
234
|
+
10,
|
|
235
|
+
10,
|
|
236
|
+
11,
|
|
237
|
+
13,
|
|
238
|
+
14,
|
|
239
|
+
16,
|
|
240
|
+
17,
|
|
241
|
+
17,
|
|
242
|
+
18,
|
|
243
|
+
20,
|
|
244
|
+
21,
|
|
245
|
+
23,
|
|
246
|
+
25,
|
|
247
|
+
26,
|
|
248
|
+
28,
|
|
249
|
+
29,
|
|
250
|
+
31,
|
|
251
|
+
33,
|
|
252
|
+
35,
|
|
253
|
+
37,
|
|
254
|
+
38,
|
|
255
|
+
40,
|
|
256
|
+
43,
|
|
257
|
+
45,
|
|
258
|
+
47,
|
|
259
|
+
49
|
|
260
|
+
],
|
|
261
|
+
Q: [
|
|
262
|
+
1,
|
|
263
|
+
1,
|
|
264
|
+
2,
|
|
265
|
+
2,
|
|
266
|
+
4,
|
|
267
|
+
4,
|
|
268
|
+
6,
|
|
269
|
+
6,
|
|
270
|
+
8,
|
|
271
|
+
8,
|
|
272
|
+
8,
|
|
273
|
+
10,
|
|
274
|
+
12,
|
|
275
|
+
16,
|
|
276
|
+
12,
|
|
277
|
+
17,
|
|
278
|
+
16,
|
|
279
|
+
18,
|
|
280
|
+
21,
|
|
281
|
+
20,
|
|
282
|
+
23,
|
|
283
|
+
23,
|
|
284
|
+
25,
|
|
285
|
+
27,
|
|
286
|
+
29,
|
|
287
|
+
34,
|
|
288
|
+
34,
|
|
289
|
+
35,
|
|
290
|
+
38,
|
|
291
|
+
40,
|
|
292
|
+
43,
|
|
293
|
+
45,
|
|
294
|
+
48,
|
|
295
|
+
51,
|
|
296
|
+
53,
|
|
297
|
+
56,
|
|
298
|
+
59,
|
|
299
|
+
62,
|
|
300
|
+
65,
|
|
301
|
+
68
|
|
302
|
+
],
|
|
303
|
+
H: [
|
|
304
|
+
1,
|
|
305
|
+
1,
|
|
306
|
+
2,
|
|
307
|
+
4,
|
|
308
|
+
4,
|
|
309
|
+
4,
|
|
310
|
+
5,
|
|
311
|
+
6,
|
|
312
|
+
8,
|
|
313
|
+
8,
|
|
314
|
+
11,
|
|
315
|
+
11,
|
|
316
|
+
16,
|
|
317
|
+
16,
|
|
318
|
+
18,
|
|
319
|
+
16,
|
|
320
|
+
19,
|
|
321
|
+
21,
|
|
322
|
+
25,
|
|
323
|
+
25,
|
|
324
|
+
25,
|
|
325
|
+
34,
|
|
326
|
+
30,
|
|
327
|
+
32,
|
|
328
|
+
35,
|
|
329
|
+
37,
|
|
330
|
+
40,
|
|
331
|
+
42,
|
|
332
|
+
45,
|
|
333
|
+
48,
|
|
334
|
+
51,
|
|
335
|
+
54,
|
|
336
|
+
57,
|
|
337
|
+
60,
|
|
338
|
+
63,
|
|
339
|
+
66,
|
|
340
|
+
70,
|
|
341
|
+
74,
|
|
342
|
+
77,
|
|
343
|
+
81
|
|
344
|
+
]
|
|
345
|
+
}, r = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
|
|
346
|
+
function i(e) {
|
|
347
|
+
let t = (16 * e + 128) * e + 64;
|
|
348
|
+
if (e >= 2) {
|
|
349
|
+
let n = Math.floor(e / 7) + 2;
|
|
350
|
+
t -= (25 * n - 10) * n - 55, e >= 7 && (t -= 36);
|
|
351
|
+
}
|
|
352
|
+
return t;
|
|
353
|
+
}
|
|
354
|
+
function a(e, r) {
|
|
355
|
+
return Math.floor(i(e) / 8) - t[r][e - 1] * n[r][e - 1];
|
|
356
|
+
}
|
|
357
|
+
function o(e) {
|
|
358
|
+
if (e === 1) return [];
|
|
359
|
+
let t = Math.floor(e / 7) + 2, n = e === 32 ? 26 : Math.ceil((e * 4 + 4) / (t * 2 - 2)) * 2, r = [6];
|
|
360
|
+
for (let i = e * 4 + 10; r.length < t; i -= n) r.splice(1, 0, i);
|
|
361
|
+
return r;
|
|
362
|
+
}
|
|
363
|
+
//#endregion
|
|
364
|
+
export { r as ALPHANUMERIC_CHARS, n as ECC_BLOCK_COUNT, t as ECC_CODEWORDS_PER_BLOCK, e as ECC_FORMAT_BITS, o as alignmentPatternPositions, a as dataCodewords, i as rawDataModules };
|
|
365
|
+
|
|
366
|
+
//# sourceMappingURL=qr-tables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qr-tables.js","names":[],"sources":["../../../src/components/QRCode/qr-tables.ts"],"sourcesContent":["/**\n * The fixed tables of ISO/IEC 18004, transcribed.\n *\n * They are data, not logic: the standard specifies them and there is nothing to\n * derive. They live apart from {@link ./qr-encode} so the algorithm reads as\n * algorithm and a typo in a table stays findable.\n */\n\n/** Error correction level, by how much of the symbol it can lose and survive. */\nexport type QRErrorCorrection = \"L\" | \"M\" | \"Q\" | \"H\";\n\nexport const ECC_LEVELS: readonly QRErrorCorrection[] = [\"L\", \"M\", \"Q\", \"H\"];\n\n/** The 2-bit code each level carries in the format information. */\nexport const ECC_FORMAT_BITS: Record<QRErrorCorrection, number> = { L: 1, M: 0, Q: 3, H: 2 };\n\n/**\n * Error-correction codewords per block, indexed `[level][version - 1]`.\n *\n * Together with {@link ECC_BLOCK_COUNT} this fixes how much of each version is\n * data and how much is redundancy.\n */\nexport const ECC_CODEWORDS_PER_BLOCK: Record<QRErrorCorrection, readonly number[]> = {\n L: [\n 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30,\n 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,\n ],\n M: [\n 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28,\n 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,\n ],\n Q: [\n 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30,\n 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,\n ],\n H: [\n 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30,\n 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,\n ],\n};\n\n/** Number of error-correction blocks, indexed `[level][version - 1]`. */\nexport const ECC_BLOCK_COUNT: Record<QRErrorCorrection, readonly number[]> = {\n L: [\n 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14,\n 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25,\n ],\n M: [\n 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23,\n 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49,\n ],\n Q: [\n 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34,\n 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68,\n ],\n H: [\n 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35,\n 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81,\n ],\n};\n\n/** The alphanumeric mode's 45-character alphabet, in code order. */\nexport const ALPHANUMERIC_CHARS = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:\";\n\n/** Lowest and highest symbol version. */\nexport const MIN_VERSION = 1;\nexport const MAX_VERSION = 40;\n\n/**\n * Total data modules in a symbol, before subtracting error correction.\n *\n * Closed form rather than a 40-row table: the function patterns a version\n * carries are themselves a function of the version, so counting them beats\n * transcribing the totals and hoping.\n *\n * @param version - Symbol version, 1 to 40.\n * @returns The module count available to data and error correction.\n */\nexport function rawDataModules(version: number): number {\n let result = (16 * version + 128) * version + 64;\n if (version >= 2) {\n const alignCount = Math.floor(version / 7) + 2;\n result -= (25 * alignCount - 10) * alignCount - 55;\n if (version >= 7) result -= 36;\n }\n return result;\n}\n\n/**\n * How many data codewords a version holds at a given level.\n *\n * @param version - Symbol version, 1 to 40.\n * @param level - Error correction level.\n * @returns Codewords left for the message itself.\n */\nexport function dataCodewords(version: number, level: QRErrorCorrection): number {\n return (\n Math.floor(rawDataModules(version) / 8) -\n ECC_CODEWORDS_PER_BLOCK[level][version - 1] * ECC_BLOCK_COUNT[level][version - 1]\n );\n}\n\n/**\n * Row/column centres of the alignment patterns for a version.\n *\n * @param version - Symbol version, 1 to 40.\n * @returns Coordinates, ascending. Empty for version 1, which has none.\n */\nexport function alignmentPatternPositions(version: number): number[] {\n if (version === 1) return [];\n const count = Math.floor(version / 7) + 2;\n // Version 32 is the one case the general spacing rule gets wrong.\n const step = version === 32 ? 26 : Math.ceil((version * 4 + 4) / (count * 2 - 2)) * 2;\n const positions = [6];\n for (let pos = version * 4 + 10; positions.length < count; pos -= step) {\n positions.splice(1, 0, pos);\n }\n return positions;\n}\n"],"mappings":";AAcA,IAAa,IAAqD;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE,GAQ9E,IAAwE;CACjF,GAAG;EACC;EAAG;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EACvF;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;CACpE;CACA,GAAG;EACC;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EACxF;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;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AAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;CACxD;CACA,GAAG;EACC;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EACtF;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;CAC5D;AACJ,GAGa,IAAqB;AAgBlC,SAAgB,EAAe,GAAyB;CACpD,IAAI,KAAU,KAAK,IAAU,OAAO,IAAU;CAC9C,IAAI,KAAW,GAAG;EACd,IAAM,IAAa,KAAK,MAAM,IAAU,CAAC,IAAI;EAE7C,AADA,MAAW,KAAK,IAAa,MAAM,IAAa,IAC5C,KAAW,MAAG,KAAU;CAChC;CACA,OAAO;AACX;AASA,SAAgB,EAAc,GAAiB,GAAkC;CAC7E,OACI,KAAK,MAAM,EAAe,CAAO,IAAI,CAAC,IACtC,EAAwB,EAAM,CAAC,IAAU,KAAK,EAAgB,EAAM,CAAC,IAAU;AAEvF;AAQA,SAAgB,EAA0B,GAA2B;CACjE,IAAI,MAAY,GAAG,OAAO,CAAC;CAC3B,IAAM,IAAQ,KAAK,MAAM,IAAU,CAAC,IAAI,GAElC,IAAO,MAAY,KAAK,KAAK,KAAK,MAAM,IAAU,IAAI,MAAM,IAAQ,IAAI,EAAE,IAAI,GAC9E,IAAY,CAAC,CAAC;CACpB,KAAK,IAAI,IAAM,IAAU,IAAI,IAAI,EAAU,SAAS,GAAO,KAAO,GAC9D,EAAU,OAAO,GAAG,GAAG,CAAG;CAE9B,OAAO;AACX"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../../utils/cn.cjs"),t=require("./scheduler-layout.cjs"),n=require("./Scheduler.module.cjs");let r=require("react"),i=require("react/jsx-runtime");var a=6e4;function o({events:o,anchor:s,days:c=7,startHour:l=8,endHour:u=20,snapMinutes:d=30,onEventClick:f,onSlotClick:p,renderEvent:m,locale:h=`pt-BR`,showCurrentTime:g=!0,now:_,className:v,...y}){let[b,x]=(0,r.useState)(()=>_??new Date);(0,r.useEffect)(()=>{if(_||!g)return;let e=setInterval(()=>x(new Date),a);return()=>clearInterval(e)},[_,g]);let S=_??b,C=(0,r.useMemo)(()=>({startMinute:l*60,endMinute:u*60}),[l,u]),w=(s??S).toDateString(),T=(0,r.useMemo)(()=>t.dayRange(new Date(w),c),[w,c]),E=(0,r.useMemo)(()=>t.layoutEvents({events:o,days:T,window:C}),[o,T,C]),D=(0,r.useMemo)(()=>t.layoutAllDay({events:o,days:T}),[o,T]),O=(0,r.useMemo)(()=>t.hourMarks(C),[C]),k=new Intl.DateTimeFormat(h,{weekday:`short`,day:`numeric`}),A=new Intl.DateTimeFormat(h,{hour:`2-digit`,minute:`2-digit`}),j=(e,t)=>{let n=t.currentTarget.getBoundingClientRect(),r=n.height>0?(t.clientY-n.top)/n.height:0,i=C.startMinute+r*(C.endMinute-C.startMinute),a=Math.round(i/d)*d,o=Math.max(C.startMinute,Math.min(C.endMinute,a)),s=new Date(e);return s.setHours(0,o,0,0),s},M=g?t.fractionOfWindow(S,C):null,N=T.findIndex(e=>t.isSameDay(e,S));return(0,i.jsxs)(`div`,{className:e.cn(n.default.wrapper,v),...y,children:[(0,i.jsxs)(`div`,{className:n.default.head,style:{"--tempest-scheduler-days":c},children:[(0,i.jsx)(`span`,{className:n.default.gutterHead}),T.map((t,r)=>(0,i.jsx)(`span`,{className:e.cn(n.default.dayHead,r===N&&n.default.today),children:k.format(t)},t.toISOString()))]}),D.length>0&&(0,i.jsxs)(`div`,{className:n.default.allDayLane,style:{"--tempest-scheduler-days":c},children:[(0,i.jsx)(`span`,{className:n.default.gutterHead,children:`Dia inteiro`}),(0,i.jsx)(`div`,{className:n.default.allDayTrack,children:D.map(({event:e,dayIndex:t,span:r})=>(0,i.jsx)(`button`,{type:`button`,className:n.default.allDayEvent,style:{gridColumn:`${t+1} / span ${r}`},onClick:()=>f?.(e),disabled:!f,children:e.title},e.id))})]}),(0,i.jsxs)(`div`,{className:n.default.body,style:{"--tempest-scheduler-days":c},tabIndex:0,role:`group`,"aria-label":`Grade de horários`,children:[(0,i.jsx)(`div`,{className:n.default.gutter,children:O.map(e=>(0,i.jsx)(`span`,{className:n.default.hourLabel,style:{top:`${(e-C.startMinute)/(C.endMinute-C.startMinute)*100}%`},children:A.format(new Date(2026,0,1,Math.floor(e/60),e%60))},e))}),(0,i.jsxs)(`div`,{className:n.default.grid,"aria-label":`Agenda`,children:[T.map((t,r)=>(0,i.jsx)(`div`,{className:e.cn(n.default.dayColumn,r===N&&n.default.todayColumn),role:`group`,"aria-label":k.format(t),onClick:p?e=>{e.target===e.currentTarget&&p(j(t,e))}:void 0,children:O.map(e=>(0,i.jsx)(`span`,{className:n.default.hourLine,style:{top:`${(e-C.startMinute)/(C.endMinute-C.startMinute)*100}%`}},e))},t.toISOString())),E.map(e=>(0,i.jsx)(`button`,{type:`button`,className:n.default.event,style:{gridColumn:e.dayIndex+1,top:`${e.top*100}%`,height:`${e.height*100}%`,left:`${e.column/e.columns*100}%`,width:`${1/e.columns*100}%`},onClick:()=>f?.(e.event),disabled:!f,title:`${e.event.title} — ${A.format(e.event.start)}`,children:m?m(e.event):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`span`,{className:n.default.eventTime,children:A.format(e.event.start)}),(0,i.jsx)(`span`,{className:n.default.eventTitle,children:e.event.title})]})},`${e.event.id}-${e.dayIndex}`)),M!==null&&N>=0&&(0,i.jsx)(`span`,{className:n.default.nowLine,style:{top:`${M*100}%`},"aria-hidden":!0,"data-testid":`scheduler-now`})]})]})]})}exports.Scheduler=o;
|
|
2
|
+
//# sourceMappingURL=Scheduler.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Scheduler.cjs","names":[],"sources":["../../../src/components/Scheduler/Scheduler.tsx"],"sourcesContent":["import { type HTMLAttributes, type ReactNode, useEffect, useMemo, useState } from \"react\";\n\nimport { cn } from \"@/utils/cn\";\n\nimport {\n dayRange,\n type DayWindow,\n fractionOfWindow,\n hourMarks,\n isSameDay,\n layoutAllDay,\n layoutEvents,\n type SchedulerEvent,\n} from \"./scheduler-layout\";\nimport styles from \"./Scheduler.module.css\";\n\nexport interface SchedulerProps extends Omit<HTMLAttributes<HTMLDivElement>, \"children\"> {\n /** Events to place. Instants are read in the browser's local time. */\n events: readonly SchedulerEvent[];\n /** Any day within the range to show. Default: today. */\n anchor?: Date;\n /** How many consecutive days to render. `1` is a day view, `7` a week. Default `7`. */\n days?: number;\n /** First visible hour, `0`–`23`. Default `8`. */\n startHour?: number;\n /** Last visible hour, `1`–`24`. Default `20`. */\n endHour?: number;\n /** Minutes a click on empty space snaps to. Default `30`. */\n snapMinutes?: number;\n /** Called when an event is activated by click, `Enter` or `Space`. */\n onEventClick?: (event: SchedulerEvent) => void;\n /** Called with the snapped instant when empty space is clicked. */\n onSlotClick?: (start: Date) => void;\n /** Render an event's contents. Defaults to its title and start time. */\n renderEvent?: (event: SchedulerEvent) => ReactNode;\n /** Locale for the day and hour labels. Default `\"pt-BR\"`. */\n locale?: string;\n /** Draw the current-time line. Default `true`. */\n showCurrentTime?: boolean;\n /** Fixed \"now\" for the indicator. Default: the real clock, ticking each minute. */\n now?: Date;\n}\n\n/** Minutes between ticks of the current-time indicator. */\nconst TICK_MS = 60_000;\n\n/**\n * An agenda: events placed on a time grid across consecutive days.\n *\n * `Calendar` is a date *picker* — it answers \"which day?\". This answers \"what is on\n * those days, and when\", which needs a different structure entirely: a vertical time\n * axis, events sized by duration, and overlapping events sitting side by side.\n *\n * That last part is the one worth naming. Overlapping events are grouped into\n * clusters of mutual overlap and every event in a cluster shares one column count,\n * so widths line up; a column is reused the moment it frees, so `9–10`, `9–10`,\n * `10–11` takes two columns and not three. The layout is pure and lives in\n * `scheduler-layout.ts`.\n *\n * Times are local. An event crossing midnight is split into both day columns, and\n * the day range is built by incrementing the calendar day, so a DST boundary does\n * not duplicate or skip a date.\n *\n * @example\n * <Scheduler\n * events={bookings}\n * days={7}\n * startHour={7}\n * endHour={21}\n * onEventClick={(e) => open(e.id)}\n * onSlotClick={(start) => createAt(start)}\n * />\n */\nexport function Scheduler({\n events,\n anchor,\n days: dayCount = 7,\n startHour = 8,\n endHour = 20,\n snapMinutes = 30,\n onEventClick,\n onSlotClick,\n renderEvent,\n locale = \"pt-BR\",\n showCurrentTime = true,\n now,\n className,\n ...rest\n}: SchedulerProps) {\n const [clock, setClock] = useState<Date>(() => now ?? new Date());\n\n /**\n * Keep the current-time line moving.\n *\n * Skipped entirely when `now` is supplied: that is the hook tests and demos use\n * to be deterministic, and a timer would fight it.\n */\n useEffect(() => {\n if (now || !showCurrentTime) return;\n const id = setInterval(() => setClock(new Date()), TICK_MS);\n return () => clearInterval(id);\n }, [now, showCurrentTime]);\n\n const reference = now ?? clock;\n\n const window = useMemo<DayWindow>(\n () => ({ startMinute: startHour * 60, endMinute: endHour * 60 }),\n [startHour, endHour],\n );\n\n /**\n * The calendar day the range starts from, as a stable string.\n *\n * `reference` ticks every minute when the current-time line is live. Depending on\n * the Date itself would re-slice the day range — and therefore relayout every\n * event — once a minute; depending on the day only recomputes at midnight.\n */\n const anchorDay = (anchor ?? reference).toDateString();\n const dayList = useMemo(() => dayRange(new Date(anchorDay), dayCount), [anchorDay, dayCount]);\n\n const placed = useMemo(\n () => layoutEvents({ events, days: dayList, window }),\n [events, dayList, window],\n );\n const allDay = useMemo(() => layoutAllDay({ events, days: dayList }), [events, dayList]);\n const marks = useMemo(() => hourMarks(window), [window]);\n\n const dayLabel = new Intl.DateTimeFormat(locale, { weekday: \"short\", day: \"numeric\" });\n const timeLabel = new Intl.DateTimeFormat(locale, { hour: \"2-digit\", minute: \"2-digit\" });\n\n /** Turn a click's vertical position within a day column into a snapped instant. */\n const slotFromClick = (day: Date, event: React.MouseEvent<HTMLDivElement>): Date => {\n const rect = event.currentTarget.getBoundingClientRect();\n const fraction = rect.height > 0 ? (event.clientY - rect.top) / rect.height : 0;\n const raw = window.startMinute + fraction * (window.endMinute - window.startMinute);\n const snapped = Math.round(raw / snapMinutes) * snapMinutes;\n const clamped = Math.max(window.startMinute, Math.min(window.endMinute, snapped));\n const result = new Date(day);\n result.setHours(0, clamped, 0, 0);\n return result;\n };\n\n const currentFraction = showCurrentTime ? fractionOfWindow(reference, window) : null;\n const todayIndex = dayList.findIndex((day) => isSameDay(day, reference));\n\n return (\n <div className={cn(styles.wrapper, className)} {...rest}>\n <div\n className={styles.head}\n style={{ [\"--tempest-scheduler-days\" as string]: dayCount }}\n >\n <span className={styles.gutterHead} />\n {dayList.map((day, index) => (\n <span\n key={day.toISOString()}\n className={cn(styles.dayHead, index === todayIndex && styles.today)}\n >\n {dayLabel.format(day)}\n </span>\n ))}\n </div>\n\n {allDay.length > 0 && (\n <div\n className={styles.allDayLane}\n style={{ [\"--tempest-scheduler-days\" as string]: dayCount }}\n >\n <span className={styles.gutterHead}>Dia inteiro</span>\n <div className={styles.allDayTrack}>\n {allDay.map(({ event, dayIndex, span }) => (\n <button\n key={event.id}\n type=\"button\"\n className={styles.allDayEvent}\n style={{ gridColumn: `${dayIndex + 1} / span ${span}` }}\n onClick={() => onEventClick?.(event)}\n disabled={!onEventClick}\n >\n {event.title}\n </button>\n ))}\n </div>\n </div>\n )}\n\n {/*\n * Focusable because it scrolls vertically: a scroll region that cannot be\n * focused is unreachable by keyboard, which is what `axe`'s\n * `scrollable-region-focusable` rule is about. It needs a name too, or the\n * new tab stop would announce nothing — but `group`, not `region`: a named\n * `region` is a landmark, and two schedulers on one page would then be two\n * identically-named landmarks (`landmark-unique`).\n */}\n <div\n className={styles.body}\n style={{ [\"--tempest-scheduler-days\" as string]: dayCount }}\n tabIndex={0}\n role=\"group\"\n aria-label=\"Grade de horários\"\n >\n <div className={styles.gutter}>\n {marks.map((minute) => (\n <span\n key={minute}\n className={styles.hourLabel}\n style={{\n top: `${((minute - window.startMinute) / (window.endMinute - window.startMinute)) * 100}%`,\n }}\n >\n {timeLabel.format(\n new Date(2026, 0, 1, Math.floor(minute / 60), minute % 60),\n )}\n </span>\n ))}\n </div>\n\n {/*\n * Not `role=\"grid\"`: that requires `row` children, and the events are\n * siblings of the day columns inside one CSS grid — a `row` wrapper\n * would stop the columns being grid items and collapse the layout.\n * A labelled group per day is the honest structure anyway: a screen\n * reader tabs the event buttons and the group name supplies the day.\n */}\n <div className={styles.grid} aria-label=\"Agenda\">\n {dayList.map((day, index) => (\n <div\n key={day.toISOString()}\n className={cn(\n styles.dayColumn,\n index === todayIndex && styles.todayColumn,\n )}\n role=\"group\"\n aria-label={dayLabel.format(day)}\n onClick={\n onSlotClick\n ? (event) => {\n // Only empty space creates: a click that\n // landed on an event is that event's.\n if (event.target !== event.currentTarget) return;\n onSlotClick(slotFromClick(day, event));\n }\n : undefined\n }\n >\n {marks.map((minute) => (\n <span\n key={minute}\n className={styles.hourLine}\n style={{\n top: `${((minute - window.startMinute) / (window.endMinute - window.startMinute)) * 100}%`,\n }}\n />\n ))}\n </div>\n ))}\n\n {placed.map((item) => (\n <button\n key={`${item.event.id}-${item.dayIndex}`}\n type=\"button\"\n className={styles.event}\n style={{\n gridColumn: item.dayIndex + 1,\n top: `${item.top * 100}%`,\n height: `${item.height * 100}%`,\n left: `${(item.column / item.columns) * 100}%`,\n width: `${(1 / item.columns) * 100}%`,\n }}\n onClick={() => onEventClick?.(item.event)}\n disabled={!onEventClick}\n title={`${item.event.title} — ${timeLabel.format(item.event.start)}`}\n >\n {renderEvent ? (\n renderEvent(item.event)\n ) : (\n <>\n <span className={styles.eventTime}>\n {timeLabel.format(item.event.start)}\n </span>\n <span className={styles.eventTitle}>{item.event.title}</span>\n </>\n )}\n </button>\n ))}\n\n {currentFraction !== null && todayIndex >= 0 && (\n <span\n className={styles.nowLine}\n style={{ top: `${currentFraction * 100}%` }}\n aria-hidden\n data-testid=\"sc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AgB,EAAO,UAAY,EAAO,aAAgB,IAAI,EAC5F,CACH,EALQ,CAKR,CACJ,CACA,EA3BI,EAAI,YAAY,CA2BpB,CACR,EAEA,EAAO,IAAK,IACT,EAAA,EAAA,IAAA,CAAC,SAAD,CAEI,KAAK,SACL,UAAW,EAAA,QAAO,MAClB,MAAO,CACH,WAAY,EAAK,SAAW,EAC5B,IAAK,GAAG,EAAK,IAAM,IAAI,GACvB,OAAQ,GAAG,EAAK,OAAS,IAAI,GAC7B,KAAM,GAAI,EAAK,OAAS,EAAK,QAAW,IAAI,GAC5C,MAAO,GAAI,EAAI,EAAK,QAAW,IAAI,EACvC,EACA,YAAe,IAAe,EAAK,KAAK,EACxC,SAAU,CAAC,EACX,MAAO,GAAG,EAAK,MAAM,MAAM,KAAK,EAAU,OAAO,EAAK,MAAM,KAAK,aAEhE,EACG,EAAY,EAAK,KAAK,GAEtB,EAAA,EAAA,KAAA,CAAA,EAAA,SAAA,CAAA,SAAA,EACI,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAW,EAAA,QAAO,mBACnB,EAAU,OAAO,EAAK,MAAM,KAAK,CAChC,CAAA,GACN,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAW,EAAA,QAAO,oBAAa,EAAK,MAAM,KAAY,CAAA,CAC9D,CAAA,CAAA,CAEF,EAxBC,GAAG,EAAK,MAAM,GAAG,GAAG,EAAK,UAwB1B,CACX,EAEA,IAAoB,MAAQ,GAAc,IACvC,EAAA,EAAA,IAAA,CAAC,OAAD,CACI,UAAW,EAAA,QAAO,QAClB,MAAO,CAAE,IAAK,GAAG,EAAkB,IAAI,EAAG,EAC1C,cAAA,GACA,cAAY,eACf,CAAA,CAEJ,GACJ,GACJ,GAEb"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { cn as e } from "../../utils/cn.js";
|
|
2
|
+
import { dayRange as t, fractionOfWindow as n, hourMarks as r, isSameDay as i, layoutAllDay as a, layoutEvents as o } from "./scheduler-layout.js";
|
|
3
|
+
import s from "./Scheduler.module.js";
|
|
4
|
+
import { useEffect as c, useMemo as l, useState as u } from "react";
|
|
5
|
+
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/Scheduler/Scheduler.tsx
|
|
7
|
+
var m = 6e4;
|
|
8
|
+
function h({ events: h, anchor: g, days: _ = 7, startHour: v = 8, endHour: y = 20, snapMinutes: b = 30, onEventClick: x, onSlotClick: S, renderEvent: C, locale: w = "pt-BR", showCurrentTime: T = !0, now: E, className: D, ...O }) {
|
|
9
|
+
let [k, A] = u(() => E ?? /* @__PURE__ */ new Date());
|
|
10
|
+
c(() => {
|
|
11
|
+
if (E || !T) return;
|
|
12
|
+
let e = setInterval(() => A(/* @__PURE__ */ new Date()), m);
|
|
13
|
+
return () => clearInterval(e);
|
|
14
|
+
}, [E, T]);
|
|
15
|
+
let j = E ?? k, M = l(() => ({
|
|
16
|
+
startMinute: v * 60,
|
|
17
|
+
endMinute: y * 60
|
|
18
|
+
}), [v, y]), N = (g ?? j).toDateString(), P = l(() => t(new Date(N), _), [N, _]), F = l(() => o({
|
|
19
|
+
events: h,
|
|
20
|
+
days: P,
|
|
21
|
+
window: M
|
|
22
|
+
}), [
|
|
23
|
+
h,
|
|
24
|
+
P,
|
|
25
|
+
M
|
|
26
|
+
]), I = l(() => a({
|
|
27
|
+
events: h,
|
|
28
|
+
days: P
|
|
29
|
+
}), [h, P]), L = l(() => r(M), [M]), R = new Intl.DateTimeFormat(w, {
|
|
30
|
+
weekday: "short",
|
|
31
|
+
day: "numeric"
|
|
32
|
+
}), z = new Intl.DateTimeFormat(w, {
|
|
33
|
+
hour: "2-digit",
|
|
34
|
+
minute: "2-digit"
|
|
35
|
+
}), B = (e, t) => {
|
|
36
|
+
let n = t.currentTarget.getBoundingClientRect(), r = n.height > 0 ? (t.clientY - n.top) / n.height : 0, i = M.startMinute + r * (M.endMinute - M.startMinute), a = Math.round(i / b) * b, o = Math.max(M.startMinute, Math.min(M.endMinute, a)), s = new Date(e);
|
|
37
|
+
return s.setHours(0, o, 0, 0), s;
|
|
38
|
+
}, V = T ? n(j, M) : null, H = P.findIndex((e) => i(e, j));
|
|
39
|
+
return /* @__PURE__ */ p("div", {
|
|
40
|
+
className: e(s.wrapper, D),
|
|
41
|
+
...O,
|
|
42
|
+
children: [
|
|
43
|
+
/* @__PURE__ */ p("div", {
|
|
44
|
+
className: s.head,
|
|
45
|
+
style: { "--tempest-scheduler-days": _ },
|
|
46
|
+
children: [/* @__PURE__ */ f("span", { className: s.gutterHead }), P.map((t, n) => /* @__PURE__ */ f("span", {
|
|
47
|
+
className: e(s.dayHead, n === H && s.today),
|
|
48
|
+
children: R.format(t)
|
|
49
|
+
}, t.toISOString()))]
|
|
50
|
+
}),
|
|
51
|
+
I.length > 0 && /* @__PURE__ */ p("div", {
|
|
52
|
+
className: s.allDayLane,
|
|
53
|
+
style: { "--tempest-scheduler-days": _ },
|
|
54
|
+
children: [/* @__PURE__ */ f("span", {
|
|
55
|
+
className: s.gutterHead,
|
|
56
|
+
children: "Dia inteiro"
|
|
57
|
+
}), /* @__PURE__ */ f("div", {
|
|
58
|
+
className: s.allDayTrack,
|
|
59
|
+
children: I.map(({ event: e, dayIndex: t, span: n }) => /* @__PURE__ */ f("button", {
|
|
60
|
+
type: "button",
|
|
61
|
+
className: s.allDayEvent,
|
|
62
|
+
style: { gridColumn: `${t + 1} / span ${n}` },
|
|
63
|
+
onClick: () => x?.(e),
|
|
64
|
+
disabled: !x,
|
|
65
|
+
children: e.title
|
|
66
|
+
}, e.id))
|
|
67
|
+
})]
|
|
68
|
+
}),
|
|
69
|
+
/* @__PURE__ */ p("div", {
|
|
70
|
+
className: s.body,
|
|
71
|
+
style: { "--tempest-scheduler-days": _ },
|
|
72
|
+
tabIndex: 0,
|
|
73
|
+
role: "group",
|
|
74
|
+
"aria-label": "Grade de horários",
|
|
75
|
+
children: [/* @__PURE__ */ f("div", {
|
|
76
|
+
className: s.gutter,
|
|
77
|
+
children: L.map((e) => /* @__PURE__ */ f("span", {
|
|
78
|
+
className: s.hourLabel,
|
|
79
|
+
style: { top: `${(e - M.startMinute) / (M.endMinute - M.startMinute) * 100}%` },
|
|
80
|
+
children: z.format(new Date(2026, 0, 1, Math.floor(e / 60), e % 60))
|
|
81
|
+
}, e))
|
|
82
|
+
}), /* @__PURE__ */ p("div", {
|
|
83
|
+
className: s.grid,
|
|
84
|
+
"aria-label": "Agenda",
|
|
85
|
+
children: [
|
|
86
|
+
P.map((t, n) => /* @__PURE__ */ f("div", {
|
|
87
|
+
className: e(s.dayColumn, n === H && s.todayColumn),
|
|
88
|
+
role: "group",
|
|
89
|
+
"aria-label": R.format(t),
|
|
90
|
+
onClick: S ? (e) => {
|
|
91
|
+
e.target === e.currentTarget && S(B(t, e));
|
|
92
|
+
} : void 0,
|
|
93
|
+
children: L.map((e) => /* @__PURE__ */ f("span", {
|
|
94
|
+
className: s.hourLine,
|
|
95
|
+
style: { top: `${(e - M.startMinute) / (M.endMinute - M.startMinute) * 100}%` }
|
|
96
|
+
}, e))
|
|
97
|
+
}, t.toISOString())),
|
|
98
|
+
F.map((e) => /* @__PURE__ */ f("button", {
|
|
99
|
+
type: "button",
|
|
100
|
+
className: s.event,
|
|
101
|
+
style: {
|
|
102
|
+
gridColumn: e.dayIndex + 1,
|
|
103
|
+
top: `${e.top * 100}%`,
|
|
104
|
+
height: `${e.height * 100}%`,
|
|
105
|
+
left: `${e.column / e.columns * 100}%`,
|
|
106
|
+
width: `${1 / e.columns * 100}%`
|
|
107
|
+
},
|
|
108
|
+
onClick: () => x?.(e.event),
|
|
109
|
+
disabled: !x,
|
|
110
|
+
title: `${e.event.title} — ${z.format(e.event.start)}`,
|
|
111
|
+
children: C ? C(e.event) : /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("span", {
|
|
112
|
+
className: s.eventTime,
|
|
113
|
+
children: z.format(e.event.start)
|
|
114
|
+
}), /* @__PURE__ */ f("span", {
|
|
115
|
+
className: s.eventTitle,
|
|
116
|
+
children: e.event.title
|
|
117
|
+
})] })
|
|
118
|
+
}, `${e.event.id}-${e.dayIndex}`)),
|
|
119
|
+
V !== null && H >= 0 && /* @__PURE__ */ f("span", {
|
|
120
|
+
className: s.nowLine,
|
|
121
|
+
style: { top: `${V * 100}%` },
|
|
122
|
+
"aria-hidden": !0,
|
|
123
|
+
"data-testid": "scheduler-now"
|
|
124
|
+
})
|
|
125
|
+
]
|
|
126
|
+
})]
|
|
127
|
+
})
|
|
128
|
+
]
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
export { h as Scheduler };
|
|
133
|
+
|
|
134
|
+
//# sourceMappingURL=Scheduler.js.map
|