@naminc/vnui 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +8 -2
- package/bin.mjs +275 -0
- package/package.json +36 -4
- package/registry/address-picker.json +64 -0
- package/registry/bank-selector.json +58 -0
- package/registry/currency-input.json +52 -0
- package/registry/lunar-date-picker.json +52 -0
- package/registry/phone-input.json +52 -0
- package/registry/registry.json +363 -0
- package/registry/tax-code-input.json +52 -0
- package/registry/vietnamese-search.json +46 -0
- package/registry/vietqr.json +44 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "bank-selector",
|
|
4
|
+
"type": "registry:block",
|
|
5
|
+
"title": "Bank Selector",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"devDependencies": [],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "components/bank-selector.tsx",
|
|
11
|
+
"type": "registry:file",
|
|
12
|
+
"target": "@components/vnui/components/bank-selector.tsx",
|
|
13
|
+
"content": "\"use client\";\nimport { useMemo, useState } from \"react\";\nimport { banks, type Bank } from \"../lib/banks\";\nimport { Combobox } from \"./combobox\";\nimport { useValue, type ValueProps } from \"../lib/state\";\nexport function BankSelector(\n p: ValueProps<string> & { entries?: readonly Bank[] },\n) {\n const [v, set] = useValue(p, \"\");\n const list = p.entries ?? banks;\n const options = useMemo(\n () =>\n list.map((b) => ({\n value: b.bin,\n label: b.shortName,\n keywords: [b.name, b.code, b.bin].join(\" \"),\n })),\n [list],\n );\n const selected = list.find((bank) => bank.bin === v);\n const [failedLogo, setFailedLogo] = useState(\"\");\n const logo = selected?.logo;\n const showLogo =\n logo && /^\\/(?!\\/)[\\w./%-]+$/.test(logo) && logo !== failedLogo;\n return (\n <div className={p.className}>\n <Combobox\n label={p.label || \"Bank\"}\n prefix={\n selected && (\n <span className=\"vn-bank-symbol\" aria-hidden=\"true\">\n {showLogo ? (\n <picture>\n <img\n src={logo}\n alt=\"\"\n width={23}\n height={20}\n onError={() => setFailedLogo(logo)}\n />\n </picture>\n ) : (\n selected.code\n )}\n </span>\n )\n }\n options={options}\n value={v}\n change={set}\n name={p.name}\n disabled={p.disabled}\n />\n </div>\n );\n}\n"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"path": "lib/banks.ts",
|
|
17
|
+
"type": "registry:file",
|
|
18
|
+
"target": "@components/vnui/lib/banks.ts",
|
|
19
|
+
"content": "import { normalizeVietnamese } from \"./search\";\n\nexport interface Bank {\n bin: string;\n code: string;\n shortName: string;\n name: string;\n /** A locally hosted logo with redistribution permission. */\n logo?: string;\n}\n\n// Factual identifiers from the VietQR.io bank directory. See docs/identifiers.md.\nexport const banks: readonly Bank[] = [\n {\n bin: \"970436\",\n code: \"VCB\",\n shortName: \"Vietcombank\",\n name: \"Ngân hàng TMCP Ngoại thương Việt Nam\",\n },\n {\n bin: \"970415\",\n code: \"ICB\",\n shortName: \"VietinBank\",\n name: \"Ngân hàng TMCP Công thương Việt Nam\",\n },\n {\n bin: \"970418\",\n code: \"BIDV\",\n shortName: \"BIDV\",\n name: \"Ngân hàng TMCP Đầu tư và Phát triển Việt Nam\",\n },\n {\n bin: \"970405\",\n code: \"VBA\",\n shortName: \"Agribank\",\n name: \"Ngân hàng Nông nghiệp và Phát triển Nông thôn Việt Nam\",\n },\n {\n bin: \"970422\",\n code: \"MB\",\n shortName: \"MBBank\",\n name: \"Ngân hàng TMCP Quân đội\",\n },\n {\n bin: \"970407\",\n code: \"TCB\",\n shortName: \"Techcombank\",\n name: \"Ngân hàng TMCP Kỹ thương Việt Nam\",\n },\n {\n bin: \"970416\",\n code: \"ACB\",\n shortName: \"ACB\",\n name: \"Ngân hàng TMCP Á Châu\",\n },\n {\n bin: \"970432\",\n code: \"VPB\",\n shortName: \"VPBank\",\n name: \"Ngân hàng TMCP Việt Nam Thịnh Vượng\",\n },\n {\n bin: \"970423\",\n code: \"TPB\",\n shortName: \"TPBank\",\n name: \"Ngân hàng TMCP Tiên Phong\",\n },\n];\n\nexport function filterBanks(\n query: string,\n entries: readonly Bank[] = banks,\n): Bank[] {\n const term = normalizeVietnamese(query.trim());\n return entries.filter(({ bin, code, shortName, name }) =>\n [bin, code, shortName, name].some((value) =>\n normalizeVietnamese(value).includes(term),\n ),\n );\n}\n"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"path": "lib/search.ts",
|
|
23
|
+
"type": "registry:file",
|
|
24
|
+
"target": "@components/vnui/lib/search.ts",
|
|
25
|
+
"content": "export function normalizeVietnamese(input: string) {\n return input\n .normalize(\"NFD\")\n .replace(/\\p{M}/gu, \"\")\n .replace(/[đĐ]/g, \"d\")\n .toLowerCase();\n}\nexport function matchRanges(\n text: string,\n query: string,\n fuzzy = false,\n): [number, number][] {\n const q = Array.from(normalizeVietnamese(query.trim()));\n if (!q.length) return [];\n const chars: string[] = [],\n bounds: [number, number][] = [];\n for (const m of text.matchAll(/\\P{M}\\p{M}*|\\p{M}+/gu)) {\n for (const c of normalizeVietnamese(m[0])) {\n chars.push(c);\n bounds.push([m.index, m.index + m[0].length]);\n }\n }\n const out: [number, number][] = [];\n let start = -1;\n for (let i = 0; i <= chars.length - q.length; i++) {\n if (q.every((v, j) => v === chars[i + j])) {\n out.push([bounds[i][0], bounds[i + q.length - 1][1]]);\n i += q.length - 1;\n }\n }\n if (out.length || !fuzzy) return out;\n for (const c of q) {\n start = chars.indexOf(c, start + 1);\n if (start < 0) return [];\n out.push(bounds[start]);\n }\n return out;\n}\n"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"path": "components/combobox.tsx",
|
|
29
|
+
"type": "registry:file",
|
|
30
|
+
"target": "@components/vnui/components/combobox.tsx",
|
|
31
|
+
"content": "\"use client\";\nimport { useState, useId } from \"react\";\nimport { normalizeVietnamese } from \"../lib/search\";\nimport \"./styles.css\";\nexport interface Option {\n value: string;\n label: string;\n keywords?: string;\n}\nexport function Combobox({\n options,\n prefix,\n value,\n change,\n label,\n disabled,\n name,\n}: {\n options: readonly Option[];\n prefix?: React.ReactNode;\n value: string;\n change: (v: string) => void;\n label: string;\n disabled?: boolean;\n name?: string;\n}) {\n const [open, show] = useState(false),\n [query, search] = useState(\"\"),\n [idx, index] = useState(0);\n const id = useId();\n const selected = options.find((o) => o.value === value),\n rows = options.filter((o) =>\n normalizeVietnamese(o.label + \" \" + (o.keywords || \"\")).includes(\n normalizeVietnamese(query),\n ),\n );\n const choose = (o: Option) => {\n change(o.value);\n show(false);\n search(\"\");\n };\n function step(i: number) {\n index(i);\n document.getElementById(id + \"-\" + i)?.scrollIntoView({ block: \"nearest\" });\n }\n return (\n <div className=\"vn-field vn-combo\">\n <label htmlFor={id}>{label}</label>\n {name && (\n <input type=\"hidden\" name={name} value={value} disabled={disabled} />\n )}\n <div className=\"vn-entry\">\n {prefix}\n <input\n id={id}\n disabled={disabled}\n role=\"combobox\"\n aria-expanded={open}\n aria-autocomplete=\"list\"\n aria-controls={open ? id + \"-list\" : undefined}\n aria-activedescendant={open && rows[idx] ? id + \"-\" + idx : undefined}\n value={open ? query : selected?.label || \"\"}\n placeholder={open ? \"Search…\" : \"Select…\"}\n onFocus={() => {\n show(true);\n search(\"\");\n index(0);\n }}\n onClick={() => show(true)}\n onBlur={() => show(false)}\n onChange={(e) => {\n search(e.target.value);\n index(0);\n show(true);\n }}\n onKeyDown={(e) => {\n if (e.key === \"Escape\") {\n show(false);\n return;\n }\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n e.preventDefault();\n show(true);\n step(\n !open\n ? 0\n : Math.max(\n 0,\n Math.min(\n rows.length - 1,\n idx + (e.key === \"ArrowDown\" ? 1 : -1),\n ),\n ),\n );\n }\n if (e.key === \"Enter\" && open) {\n e.preventDefault();\n if (rows[idx]) choose(rows[idx]);\n }\n }}\n />\n <span className=\"vn-chevron\" aria-hidden=\"true\">\n ⌄\n </span>\n </div>\n {open && (\n <div\n role=\"listbox\"\n id={id + \"-list\"}\n aria-label={label}\n className=\"vn-options\"\n >\n {rows.map((o, i) => (\n <div\n role=\"option\"\n id={id + \"-\" + i}\n aria-selected={o.value === value}\n data-active={i === idx}\n key={o.value}\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => choose(o)}\n >\n {o.label}\n </div>\n ))}\n {!rows.length && <div role=\"status\">No matches</div>}\n </div>\n )}\n </div>\n );\n}\n"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"path": "components/styles.css",
|
|
35
|
+
"type": "registry:file",
|
|
36
|
+
"target": "@components/vnui/components/styles.css",
|
|
37
|
+
"content": ".vn-bank-symbol {\n font: 600 0.7rem/1.2 system-ui;\n letter-spacing: 0.02em;\n color: var(--vn-ink, CanvasText);\n padding: 3px 5px;\n margin-left: 0.7rem;\n border: 1px solid var(--vn-border, #888);\n border-radius: 3px;\n}\n.vn-bank-symbol img {\n object-fit: contain;\n}\n.vn-lunar-fields {\n display: grid;\n grid-template-columns: 1fr 1fr 1.4fr;\n gap: 0.5rem;\n}\n.vn-field .vn-apply {\n justify-self: start;\n border: 1px solid var(--vn-border, #777);\n border-radius: 4px;\n padding: 5px 10px;\n font-size: 0.82rem;\n background: var(--vn-input, Canvas);\n color: inherit;\n cursor: pointer;\n}\n.vn-stack,\n.vn-field,\n.vn-qr {\n display: grid;\n gap: 0.55rem;\n min-width: 0;\n}\n.vn-stack {\n gap: 1rem;\n}\n.vn-field label,\n.vn-qr figcaption {\n font: 500 0.81rem/1.5 var(--font-geist-sans, system-ui);\n color: inherit;\n}\n.vn-field input:not([type=\"hidden\"]):not([type=\"checkbox\"]),\n.vn-entry {\n border: 1px solid var(--vn-border, #747474);\n background: var(--vn-input, Canvas);\n color: var(--vn-ink, CanvasText);\n border-radius: 6px;\n min-width: 0;\n width: 100%;\n box-sizing: border-box;\n font: 400 0.91rem/1.3 var(--font-geist-mono, monospace);\n height: 42px;\n padding: 0 0.8rem;\n}\n.vn-lunar-leap {\n display: inline-flex;\n align-items: center;\n gap: 0.5rem;\n justify-self: start;\n font-size: 0.875rem;\n cursor: pointer;\n}\n.vn-field .vn-lunar-leap input[type=\"checkbox\"] {\n width: 1rem;\n height: 1rem;\n margin: 0;\n padding: 0;\n accent-color: var(--vn-focus, #67ab94);\n}\n.vn-entry {\n display: flex;\n align-items: center;\n padding: 0;\n overflow: hidden;\n}\n.vn-entry input:not([type=\"hidden\"]) {\n border: 0;\n background: transparent;\n flex: 1;\n outline: none;\n}\n.vn-entry:focus-within,\n.vn-field > input:focus-visible {\n outline: 2px solid var(--vn-focus, #67ab94);\n outline-offset: 2px;\n}\n.vn-field small,\n.vn-qr small {\n color: var(--vn-error, #e08a85);\n}\n.vn-unit,\n.vn-chevron {\n padding: 0 0.8rem;\n color: var(--muted, inherit);\n}\n.vn-country {\n display: flex;\n gap: 0.4rem;\n align-items: center;\n font: 500 0.75rem system-ui;\n margin-left: 0.75rem;\n padding-right: 0.7rem;\n border-right: 1px solid var(--vn-border, #777);\n}\n.vn-country i {\n font: normal 11px/13px sans-serif;\n color: #ffde78;\n background: #b84244;\n padding: 0 3px;\n border-radius: 2px;\n}\n.vn-combo {\n position: relative;\n}\n.vn-options {\n position: absolute;\n z-index: 12;\n top: 100%;\n margin-top: 4px;\n left: 0;\n right: 0;\n background: var(--vn-input, Canvas);\n color: var(--vn-ink, CanvasText);\n border: 1px solid var(--vn-border, #777);\n border-radius: 6px;\n padding: 4px;\n max-height: 220px;\n overflow: auto;\n text-align: left;\n}\n.vn-options > div {\n padding: 0.5rem;\n cursor: pointer;\n font-size: 0.875rem;\n}\n.vn-options > [data-active=\"true\"],\n.vn-options > div:hover {\n background: var(--vn-highlight, Highlight);\n color: var(--vn-highlight-ink, HighlightText);\n}\n.vn-matches {\n list-style: none;\n padding: 0;\n margin: 0;\n}\n.vn-matches li {\n padding: 0.45rem 0;\n}\n.vn-matches mark {\n background: #b3e3c7;\n color: #173222;\n}\n.vn-qr {\n justify-items: start;\n margin: 0;\n}\n.vn-qr img {\n max-width: 100%;\n height: auto;\n}\n.vn-qr a {\n margin-right: 1rem;\n text-decoration: underline;\n font-size: 0.85rem;\n}\n.vn-field output {\n font-family: monospace;\n font-size: 0.9rem;\n}\n"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"path": "components/styles.css.d.ts",
|
|
41
|
+
"type": "registry:file",
|
|
42
|
+
"target": "@components/vnui/components/styles.css.d.ts",
|
|
43
|
+
"content": "/** Side-effect stylesheet import for strict TypeScript consumers. */\nexport {};\n"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"path": "lib/state.ts",
|
|
47
|
+
"type": "registry:file",
|
|
48
|
+
"target": "@components/vnui/lib/state.ts",
|
|
49
|
+
"content": "\"use client\";\nimport { useState } from \"react\";\nexport type ValueProps<T> = {\n value?: T;\n defaultValue?: T;\n onValueChange?: (value: T) => void;\n className?: string;\n label?: string;\n name?: string;\n disabled?: boolean;\n};\nexport function useValue<T>(\n props: ValueProps<T>,\n fallback: T,\n): [T, (v: T) => void] {\n const [local, setLocal] = useState<T>(\n props.defaultValue === undefined ? fallback : props.defaultValue,\n );\n return [\n props.value === undefined ? local : props.value,\n (v: T) => {\n if (props.value === undefined) setLocal(v);\n props.onValueChange?.(v);\n },\n ];\n}\n"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"path": "LICENSE",
|
|
53
|
+
"type": "registry:file",
|
|
54
|
+
"target": "@components/vnui/LICENSE",
|
|
55
|
+
"content": "MIT License\r\n\r\nCopyright (c) 2026 Ngo Dinh Nam\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE.\r\n"
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "currency-input",
|
|
4
|
+
"type": "registry:block",
|
|
5
|
+
"title": "Currency Input",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"devDependencies": [],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "components/currency-input.tsx",
|
|
11
|
+
"type": "registry:file",
|
|
12
|
+
"target": "@components/vnui/components/currency-input.tsx",
|
|
13
|
+
"content": "\"use client\";\nimport { useId, useRef, useState, type Ref } from \"react\";\nimport { formatCurrency } from \"../lib/currency\";\nimport { useValue, type ValueProps } from \"../lib/state\";\nimport { useValidity } from \"../lib/validity\";\nimport \"./styles.css\";\nexport function CurrencyInput({\n ref,\n ...p\n}: ValueProps<bigint | null> & {\n min?: bigint;\n max?: bigint;\n symbol?: string;\n ref?: Ref<HTMLInputElement>;\n onBlur?: () => void;\n}) {\n const [v, set] = useValue(p, null),\n [minus, setMinus] = useState(false);\n const id = useId(),\n version = useRef(0);\n const error =\n v !== null &&\n ((p.min !== undefined && v < p.min) || (p.max !== undefined && v > p.max));\n const message = error\n ? `Amount must be within ${p.min?.toString() ?? \"−∞\"} to ${p.max?.toString() ?? \"∞\"}.`\n : \"\";\n const inputRef = useValidity(message, ref);\n return (\n <div className={\"vn-field \" + (p.className || \"\")}>\n <label htmlFor={id}>{p.label || \"Amount\"}</label>\n <div className=\"vn-entry\">\n <input\n id={id}\n ref={inputRef}\n name={p.name}\n disabled={p.disabled}\n inputMode=\"numeric\"\n autoComplete=\"off\"\n placeholder=\"0\"\n aria-invalid={error}\n aria-describedby={error ? id + \"-err\" : undefined}\n value={minus && v === null ? \"-\" : formatCurrency(v, \"\")}\n onKeyDown={(e) => {\n const input = e.currentTarget,\n start = input.selectionStart,\n end = input.selectionEnd;\n if (start === null || start !== end) return;\n if (e.key === \"Backspace\" && input.value[start - 1] === \".\")\n input.setSelectionRange(Math.max(0, start - 2), start);\n if (e.key === \"Delete\" && input.value[start] === \".\")\n input.setSelectionRange(start, start + 2);\n }}\n onBlur={() => {\n setMinus(false);\n p.onBlur?.();\n }}\n onChange={(e) => {\n const el = e.currentTarget;\n const raw = el.value;\n if (!/^-?[\\d.\\s]*$/.test(raw)) return;\n const caret = el.selectionStart ?? raw.length;\n const digits = raw.slice(0, caret).replace(/\\D/g, \"\").length;\n const s = raw.replace(/[.\\s]/g, \"\");\n setMinus(s === \"-\");\n set(!s || s === \"-\" ? null : BigInt(s));\n const seq = ++version.current;\n requestAnimationFrame(() => {\n if (seq !== version.current || document.activeElement !== el)\n return;\n let pos = el.value.startsWith(\"-\") ? 1 : 0,\n count = 0;\n while (pos < el.value.length && count < digits) {\n if (/\\d/.test(el.value[pos])) count++;\n pos++;\n }\n el.setSelectionRange(pos, pos);\n });\n }}\n />\n <span className=\"vn-unit\">{p.symbol ?? \"₫\"}</span>\n </div>\n {error && (\n <small id={id + \"-err\"} role=\"alert\">\n {message}\n </small>\n )}\n </div>\n );\n}\n"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"path": "lib/currency.ts",
|
|
17
|
+
"type": "registry:file",
|
|
18
|
+
"target": "@components/vnui/lib/currency.ts",
|
|
19
|
+
"content": "export function parseCurrency(text: string): bigint | null {\n const s = text.trim();\n if (!s) return null;\n if (!/^-?(?:\\d+|\\d{1,3}(?:\\.\\d{3})+)(?:\\s*₫)?$/.test(s))\n throw new RangeError(\"Enter a whole VND amount\");\n return BigInt(s.replace(/[.\\s₫]/g, \"\"));\n}\nexport const formatCurrency = (amount: bigint | null, symbol = \"₫\") =>\n amount === null\n ? \"\"\n : new Intl.NumberFormat(\"vi-VN\").format(amount) +\n (symbol ? \" \" + symbol : \"\");\n"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"path": "lib/state.ts",
|
|
23
|
+
"type": "registry:file",
|
|
24
|
+
"target": "@components/vnui/lib/state.ts",
|
|
25
|
+
"content": "\"use client\";\nimport { useState } from \"react\";\nexport type ValueProps<T> = {\n value?: T;\n defaultValue?: T;\n onValueChange?: (value: T) => void;\n className?: string;\n label?: string;\n name?: string;\n disabled?: boolean;\n};\nexport function useValue<T>(\n props: ValueProps<T>,\n fallback: T,\n): [T, (v: T) => void] {\n const [local, setLocal] = useState<T>(\n props.defaultValue === undefined ? fallback : props.defaultValue,\n );\n return [\n props.value === undefined ? local : props.value,\n (v: T) => {\n if (props.value === undefined) setLocal(v);\n props.onValueChange?.(v);\n },\n ];\n}\n"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"path": "lib/validity.ts",
|
|
29
|
+
"type": "registry:file",
|
|
30
|
+
"target": "@components/vnui/lib/validity.ts",
|
|
31
|
+
"content": "\"use client\";\nimport { useImperativeHandle, useLayoutEffect, useRef, type Ref } from \"react\";\n/** Keep native form submission and a form library's focus ref in sync with validation. */\nexport function useValidity(\n message: string,\n forwarded?: Ref<HTMLInputElement>,\n) {\n const input = useRef<HTMLInputElement>(null);\n useImperativeHandle(forwarded, () => input.current!, []);\n useLayoutEffect(() => {\n input.current?.setCustomValidity(message);\n }, [message]);\n return input;\n}\n"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"path": "components/styles.css",
|
|
35
|
+
"type": "registry:file",
|
|
36
|
+
"target": "@components/vnui/components/styles.css",
|
|
37
|
+
"content": ".vn-bank-symbol {\n font: 600 0.7rem/1.2 system-ui;\n letter-spacing: 0.02em;\n color: var(--vn-ink, CanvasText);\n padding: 3px 5px;\n margin-left: 0.7rem;\n border: 1px solid var(--vn-border, #888);\n border-radius: 3px;\n}\n.vn-bank-symbol img {\n object-fit: contain;\n}\n.vn-lunar-fields {\n display: grid;\n grid-template-columns: 1fr 1fr 1.4fr;\n gap: 0.5rem;\n}\n.vn-field .vn-apply {\n justify-self: start;\n border: 1px solid var(--vn-border, #777);\n border-radius: 4px;\n padding: 5px 10px;\n font-size: 0.82rem;\n background: var(--vn-input, Canvas);\n color: inherit;\n cursor: pointer;\n}\n.vn-stack,\n.vn-field,\n.vn-qr {\n display: grid;\n gap: 0.55rem;\n min-width: 0;\n}\n.vn-stack {\n gap: 1rem;\n}\n.vn-field label,\n.vn-qr figcaption {\n font: 500 0.81rem/1.5 var(--font-geist-sans, system-ui);\n color: inherit;\n}\n.vn-field input:not([type=\"hidden\"]):not([type=\"checkbox\"]),\n.vn-entry {\n border: 1px solid var(--vn-border, #747474);\n background: var(--vn-input, Canvas);\n color: var(--vn-ink, CanvasText);\n border-radius: 6px;\n min-width: 0;\n width: 100%;\n box-sizing: border-box;\n font: 400 0.91rem/1.3 var(--font-geist-mono, monospace);\n height: 42px;\n padding: 0 0.8rem;\n}\n.vn-lunar-leap {\n display: inline-flex;\n align-items: center;\n gap: 0.5rem;\n justify-self: start;\n font-size: 0.875rem;\n cursor: pointer;\n}\n.vn-field .vn-lunar-leap input[type=\"checkbox\"] {\n width: 1rem;\n height: 1rem;\n margin: 0;\n padding: 0;\n accent-color: var(--vn-focus, #67ab94);\n}\n.vn-entry {\n display: flex;\n align-items: center;\n padding: 0;\n overflow: hidden;\n}\n.vn-entry input:not([type=\"hidden\"]) {\n border: 0;\n background: transparent;\n flex: 1;\n outline: none;\n}\n.vn-entry:focus-within,\n.vn-field > input:focus-visible {\n outline: 2px solid var(--vn-focus, #67ab94);\n outline-offset: 2px;\n}\n.vn-field small,\n.vn-qr small {\n color: var(--vn-error, #e08a85);\n}\n.vn-unit,\n.vn-chevron {\n padding: 0 0.8rem;\n color: var(--muted, inherit);\n}\n.vn-country {\n display: flex;\n gap: 0.4rem;\n align-items: center;\n font: 500 0.75rem system-ui;\n margin-left: 0.75rem;\n padding-right: 0.7rem;\n border-right: 1px solid var(--vn-border, #777);\n}\n.vn-country i {\n font: normal 11px/13px sans-serif;\n color: #ffde78;\n background: #b84244;\n padding: 0 3px;\n border-radius: 2px;\n}\n.vn-combo {\n position: relative;\n}\n.vn-options {\n position: absolute;\n z-index: 12;\n top: 100%;\n margin-top: 4px;\n left: 0;\n right: 0;\n background: var(--vn-input, Canvas);\n color: var(--vn-ink, CanvasText);\n border: 1px solid var(--vn-border, #777);\n border-radius: 6px;\n padding: 4px;\n max-height: 220px;\n overflow: auto;\n text-align: left;\n}\n.vn-options > div {\n padding: 0.5rem;\n cursor: pointer;\n font-size: 0.875rem;\n}\n.vn-options > [data-active=\"true\"],\n.vn-options > div:hover {\n background: var(--vn-highlight, Highlight);\n color: var(--vn-highlight-ink, HighlightText);\n}\n.vn-matches {\n list-style: none;\n padding: 0;\n margin: 0;\n}\n.vn-matches li {\n padding: 0.45rem 0;\n}\n.vn-matches mark {\n background: #b3e3c7;\n color: #173222;\n}\n.vn-qr {\n justify-items: start;\n margin: 0;\n}\n.vn-qr img {\n max-width: 100%;\n height: auto;\n}\n.vn-qr a {\n margin-right: 1rem;\n text-decoration: underline;\n font-size: 0.85rem;\n}\n.vn-field output {\n font-family: monospace;\n font-size: 0.9rem;\n}\n"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"path": "components/styles.css.d.ts",
|
|
41
|
+
"type": "registry:file",
|
|
42
|
+
"target": "@components/vnui/components/styles.css.d.ts",
|
|
43
|
+
"content": "/** Side-effect stylesheet import for strict TypeScript consumers. */\nexport {};\n"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"path": "LICENSE",
|
|
47
|
+
"type": "registry:file",
|
|
48
|
+
"target": "@components/vnui/LICENSE",
|
|
49
|
+
"content": "MIT License\r\n\r\nCopyright (c) 2026 Ngo Dinh Nam\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE.\r\n"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "lunar-date-picker",
|
|
4
|
+
"type": "registry:block",
|
|
5
|
+
"title": "Lunar Date Picker",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"devDependencies": [],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "components/lunar-date-picker.tsx",
|
|
11
|
+
"type": "registry:file",
|
|
12
|
+
"target": "@components/vnui/components/lunar-date-picker.tsx",
|
|
13
|
+
"content": "\"use client\";\nimport { LunarEditor } from \"./lunar-editor\";\nimport { useId, useState } from \"react\";\nimport {\n LUNAR_MIN,\n LUNAR_MAX,\n vietnamDate,\n gregorianToLunar,\n} from \"../lib/lunar\";\nimport { useValue, type ValueProps } from \"../lib/state\";\nimport \"./styles.css\";\nexport function LunarDatePicker(\n p: ValueProps<string> & { min?: string; max?: string; locale?: \"en\" | \"vi\" },\n) {\n const [v, set] = useValue(p, vietnamDate());\n const [editing, edit] = useState(false);\n const vi = p.locale === \"vi\";\n const id = useId(),\n min = p.min && p.min > LUNAR_MIN ? p.min : LUNAR_MIN,\n max = p.max && p.max < LUNAR_MAX ? p.max : LUNAR_MAX;\n let result = \"\";\n let invalid = false;\n if (v) {\n try {\n if (v < min || v > max) throw new RangeError();\n const l = gregorianToLunar(v);\n result =\n [l.day, l.month, l.year].join(\" / \") +\n (l.leap ? (vi ? \" · tháng nhuận\" : \" · leap month\") : \"\") +\n (vi ? \" ÂL\" : \" Lunar\");\n } catch {\n invalid = true;\n }\n }\n return (\n <div className={\"vn-field \" + (p.className || \"\")}>\n <label htmlFor={id}>{p.label || \"Gregorian date\"}</label>\n <input\n id={id}\n type=\"date\"\n min={min}\n max={max}\n name={p.name}\n value={v}\n disabled={p.disabled}\n aria-invalid={invalid}\n aria-describedby={id + \"-result\"}\n onChange={(e) => set(e.target.value)}\n />\n <output id={id + \"-result\"} aria-live=\"polite\">\n {invalid\n ? vi\n ? \"Chọn ngày từ \" + min + \" đến \" + max\n : \"Choose a date from \" + min + \" to \" + max\n : result}\n </output>\n <button\n className=\"vn-apply\"\n type=\"button\"\n disabled={p.disabled}\n aria-expanded={editing}\n onClick={() => edit(!editing)}\n >\n {vi ? \"Nhập ngày âm lịch\" : \"Enter lunar date\"}\n </button>\n {editing && !p.disabled && (\n <LunarEditor\n key={v}\n date={gregorianToLunar(\n v && !invalid\n ? v\n : min <= vietnamDate() && vietnamDate() <= max\n ? vietnamDate()\n : LUNAR_MIN,\n )}\n min={min}\n max={max}\n vi={vi}\n apply={(iso) => {\n set(iso);\n edit(false);\n }}\n />\n )}\n </div>\n );\n}\n"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"path": "components/lunar-editor.tsx",
|
|
17
|
+
"type": "registry:file",
|
|
18
|
+
"target": "@components/vnui/components/lunar-editor.tsx",
|
|
19
|
+
"content": "\"use client\";\nimport { useId, useState } from \"react\";\nimport { lunarToGregorian, type LunarDate } from \"../lib/lunar\";\nexport function LunarEditor({\n date,\n min,\n max,\n apply,\n vi,\n}: {\n date: LunarDate;\n min: string;\n max: string;\n apply: (iso: string) => void;\n vi: boolean;\n}) {\n const [draft, setDraft] = useState(date);\n const [error, setError] = useState(\"\");\n const id = useId();\n return (\n <div className=\"vn-stack\">\n <div className=\"vn-lunar-fields\">\n {([\"day\", \"month\", \"year\"] as const).map((key, i) => (\n <label className=\"vn-field\" key={key}>\n {\n (vi\n ? [\"Ngày âm\", \"Tháng âm\", \"Năm âm\"]\n : [\"Lunar day\", \"Lunar month\", \"Lunar year\"])[i]\n }\n <input\n type=\"number\"\n min={i === 2 ? 1975 : 1}\n max={[30, 12, 2099][i]}\n value={draft[key] || \"\"}\n onChange={(e) => {\n setDraft({ ...draft, [key]: Number(e.target.value) });\n setError(\"\");\n }}\n />\n </label>\n ))}\n </div>\n <label className=\"vn-lunar-leap\">\n <input\n type=\"checkbox\"\n checked={draft.leap}\n onChange={(e) => setDraft({ ...draft, leap: e.target.checked })}\n />\n {vi ? \"Tháng nhuận\" : \"Leap month\"}\n </label>\n <button\n className=\"vn-apply\"\n type=\"button\"\n aria-describedby={error ? id : undefined}\n onClick={() => {\n try {\n const iso = lunarToGregorian(draft);\n if (iso < min || iso > max) throw Error();\n apply(iso);\n } catch {\n setError(\n vi\n ? \"Ngày âm lịch không hợp lệ hoặc nằm ngoài phạm vi.\"\n : \"Choose a valid lunar date within the supported range.\",\n );\n }\n }}\n >\n {vi ? \"Chọn ngày\" : \"Apply date\"}\n </button>\n {error && (\n <small id={id} role=\"alert\">\n {error}\n </small>\n )}\n </div>\n );\n}\n"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"path": "lib/lunar.ts",
|
|
23
|
+
"type": "registry:file",
|
|
24
|
+
"target": "@components/vnui/lib/lunar.ts",
|
|
25
|
+
"content": "/** Gregorian civil dates, inclusive. All astronomical boundaries use UTC+07:00. */\nexport const LUNAR_MIN = \"1976-01-01\";\nexport const LUNAR_MAX = \"2099-12-31\";\n\nexport interface LunarDate {\n year: number;\n month: number;\n day: number;\n leap: boolean;\n}\n\nconst millisecondsPerDay = 86_400_000;\n\n// Each row gives the Gregorian date of Tết and consecutive lunar month lengths.\n// A negative length indicates a leap month repeating the previous month's number.\n// Generated by scripts/generate-lunar.mjs using Astronomy Engine v2.1.19 (UTC+7).\n// prettier-ignore\nconst years: Readonly<Record<number, readonly [string, readonly number[]]>> = {\n // BEGIN YEARS\n 1975: [\"1975-02-11\", [30, 29, 30, 30, 29, 29, 30, 29, 29, 30, 29, 30]],\n 1976: [\"1976-01-31\", [30, 30, 29, 30, 29, 30, 29, 30, -29, 29, 30, 29, 30]],\n 1977: [\"1977-02-18\", [30, 29, 30, 30, 29, 30, 29, 30, 29, 30, 29, 29]],\n 1978: [\"1978-02-07\", [30, 29, 30, 30, 29, 30, 29, 30, 30, 29, 30, 29]],\n 1979: [\"1979-01-28\", [29, 30, 29, 30, 29, 30, -30, 29, 30, 30, 29, 30, 29]],\n 1980: [\"1980-02-16\", [30, 29, 29, 30, 29, 30, 29, 30, 30, 29, 30, 30]],\n 1981: [\"1981-02-05\", [29, 30, 29, 29, 30, 29, 29, 30, 30, 29, 30, 30]],\n 1982: [\"1982-01-25\", [30, 29, 30, 29, -29, 30, 29, 29, 30, 29, 30, 30, 30]],\n 1983: [\"1983-02-13\", [30, 29, 30, 29, 29, 30, 29, 29, 30, 29, 30, 30]],\n 1984: [\"1984-02-02\", [30, 29, 30, 29, 30, 29, 30, 29, 29, 30, 29, 30]],\n 1985: [\"1985-01-21\", [30, 29, -30, 30, 29, 30, 29, 30, 29, 29, 30, 29, 30]],\n 1986: [\"1986-02-09\", [29, 30, 30, 29, 30, 30, 29, 30, 29, 29, 30, 29]],\n 1987: [\"1987-01-29\", [30, 29, 30, 29, 30, 30, 29, -30, 30, 29, 30, 29, 29]],\n 1988: [\"1988-02-17\", [30, 29, 30, 29, 30, 29, 30, 30, 29, 30, 30, 29]],\n 1989: [\"1989-02-06\", [30, 29, 29, 30, 29, 29, 30, 30, 29, 30, 30, 30]],\n 1990: [\"1990-01-27\", [29, 30, 29, 29, 30, -29, 29, 30, 29, 30, 30, 30, 30]],\n 1991: [\"1991-02-15\", [29, 30, 29, 29, 30, 29, 29, 30, 29, 30, 30, 30]],\n 1992: [\"1992-02-04\", [29, 30, 30, 29, 29, 30, 29, 29, 30, 29, 30, 30]],\n 1993: [\"1993-01-23\", [29, 30, 30, -29, 30, 29, 30, 29, 29, 30, 29, 30, 29]],\n 1994: [\"1994-02-10\", [30, 30, 30, 29, 30, 29, 30, 29, 29, 30, 29, 30]],\n 1995: [\"1995-01-31\", [29, 30, 30, 29, 30, 29, 30, 29, -30, 29, 30, 29, 30]],\n 1996: [\"1996-02-19\", [29, 30, 29, 30, 29, 30, 30, 29, 30, 29, 30, 29]],\n 1997: [\"1997-02-07\", [30, 29, 30, 29, 30, 29, 30, 29, 30, 30, 29, 30]],\n 1998: [\"1998-01-28\", [30, 29, 29, 30, 29, -29, 30, 30, 29, 30, 30, 29, 30]],\n 1999: [\"1999-02-16\", [30, 29, 29, 30, 29, 29, 30, 29, 30, 30, 30, 29]],\n 2000: [\"2000-02-05\", [30, 30, 29, 29, 30, 29, 29, 30, 29, 30, 30, 29]],\n 2001: [\"2001-01-24\", [30, 30, 29, 30, -29, 30, 29, 29, 30, 29, 30, 29, 30]],\n 2002: [\"2002-02-12\", [30, 30, 29, 30, 29, 30, 29, 29, 30, 29, 30, 29]],\n 2003: [\"2003-02-01\", [30, 30, 29, 30, 30, 29, 30, 29, 29, 30, 29, 30]],\n 2004: [\"2004-01-22\", [29, 30, -29, 30, 30, 29, 30, 29, 30, 29, 30, 29, 30]],\n 2005: [\"2005-02-09\", [29, 30, 29, 30, 29, 30, 30, 29, 30, 29, 30, 29]],\n 2006: [\"2006-01-29\", [30, 29, 30, 29, 29, 30, 30, -29, 30, 30, 29, 30, 29]],\n 2007: [\"2007-02-17\", [30, 29, 30, 29, 29, 30, 29, 30, 30, 30, 29, 30]],\n 2008: [\"2008-02-07\", [30, 29, 29, 30, 29, 29, 30, 29, 30, 29, 30, 30]],\n 2009: [\"2009-01-26\", [30, 29, 30, 29, 30, -29, 29, 30, 29, 30, 29, 30, 30]],\n 2010: [\"2010-02-14\", [30, 29, 30, 29, 30, 29, 29, 30, 29, 30, 29, 30]],\n 2011: [\"2011-02-03\", [30, 29, 30, 30, 29, 30, 29, 29, 30, 29, 30, 29]],\n 2012: [\"2012-01-23\", [30, 29, 30, 30, -29, 30, 29, 30, 29, 30, 29, 30, 29]],\n 2013: [\"2013-02-10\", [30, 29, 30, 29, 30, 30, 29, 30, 29, 30, 29, 30]],\n 2014: [\"2014-01-31\", [29, 30, 29, 30, 29, 30, 29, 30, 30, -29, 30, 29, 30]],\n 2015: [\"2015-02-19\", [29, 30, 29, 29, 30, 29, 30, 30, 30, 29, 30, 29]],\n 2016: [\"2016-02-08\", [30, 29, 30, 29, 29, 30, 29, 30, 30, 29, 30, 30]],\n 2017: [\"2017-01-28\", [29, 30, 29, 30, 29, 29, -30, 29, 30, 29, 30, 30, 30]],\n 2018: [\"2018-02-16\", [29, 30, 29, 30, 29, 29, 30, 29, 29, 30, 30, 30]],\n 2019: [\"2019-02-05\", [29, 30, 30, 29, 30, 29, 29, 30, 29, 29, 30, 30]],\n 2020: [\"2020-01-25\", [29, 30, 30, 30, -29, 30, 29, 29, 30, 29, 29, 30, 30]],\n 2021: [\"2021-02-12\", [29, 30, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29]],\n 2022: [\"2022-02-01\", [30, 29, 30, 29, 30, 30, 29, 30, 29, 30, 29, 30]],\n 2023: [\"2023-01-22\", [29, 30, -29, 29, 30, 30, 29, 30, 30, 29, 30, 29, 30]],\n 2024: [\"2024-02-10\", [29, 30, 29, 29, 30, 29, 30, 30, 29, 30, 30, 29]],\n 2025: [\"2025-01-29\", [30, 29, 30, 29, 29, 30, -29, 30, 29, 30, 30, 30, 29]],\n 2026: [\"2026-02-17\", [30, 29, 30, 29, 29, 30, 29, 29, 30, 30, 30, 29]],\n 2027: [\"2027-02-06\", [30, 30, 29, 30, 29, 29, 30, 29, 29, 30, 30, 29]],\n 2028: [\"2028-01-26\", [30, 30, 30, 29, 30, -29, 29, 30, 29, 29, 30, 30, 29]],\n 2029: [\"2029-02-13\", [30, 30, 29, 30, 29, 30, 29, 30, 29, 29, 30, 29]],\n 2030: [\"2030-02-02\", [30, 30, 29, 30, 30, 29, 30, 29, 30, 29, 30, 29]],\n 2031: [\"2031-01-23\", [29, 30, 29, -30, 30, 29, 30, 30, 29, 30, 29, 30, 29]],\n 2032: [\"2032-02-11\", [29, 30, 29, 30, 29, 30, 30, 29, 30, 30, 29, 30]],\n 2033: [\"2033-01-31\", [29, 30, 29, 29, 30, 29, 30, 29, 30, 30, 30, -29, 30]],\n 2034: [\"2034-02-19\", [29, 30, 29, 29, 30, 29, 29, 30, 30, 30, 29, 30]],\n 2035: [\"2035-02-08\", [30, 29, 30, 29, 29, 30, 29, 29, 30, 30, 29, 30]],\n 2036: [\"2036-01-28\", [30, 30, 29, 30, 29, 29, -30, 29, 29, 30, 29, 30, 30]],\n 2037: [\"2037-02-15\", [30, 29, 30, 30, 29, 29, 30, 29, 29, 30, 29, 30]],\n 2038: [\"2038-02-04\", [30, 29, 30, 30, 29, 30, 29, 30, 29, 29, 30, 29]],\n 2039: [\"2039-01-24\", [30, 30, 29, 30, 30, -29, 30, 29, 30, 29, 29, 30, 29]],\n 2040: [\"2040-02-12\", [30, 29, 30, 30, 29, 30, 29, 30, 30, 29, 30, 29]],\n 2041: [\"2041-02-01\", [29, 30, 29, 30, 29, 30, 29, 30, 30, 30, 29, 30]],\n 2042: [\"2042-01-22\", [29, 30, -29, 29, 30, 29, 30, 29, 30, 30, 29, 30, 30]],\n 2043: [\"2043-02-10\", [29, 30, 29, 29, 30, 29, 29, 30, 30, 29, 30, 30]],\n 2044: [\"2044-01-30\", [30, 29, 30, 29, 29, 30, 29, -29, 30, 29, 30, 30, 30]],\n 2045: [\"2045-02-17\", [30, 29, 30, 29, 29, 30, 29, 29, 30, 29, 30, 30]],\n 2046: [\"2046-02-06\", [30, 29, 30, 29, 30, 29, 30, 29, 29, 30, 29, 30]],\n 2047: [\"2047-01-26\", [30, 29, 30, 30, 29, -30, 29, 30, 29, 29, 30, 29, 30]],\n 2048: [\"2048-02-14\", [29, 30, 30, 29, 30, 30, 29, 30, 29, 29, 30, 29]],\n 2049: [\"2049-02-02\", [30, 29, 30, 29, 30, 30, 29, 30, 29, 30, 30, 29]],\n 2050: [\"2050-01-23\", [29, 30, 29, -30, 29, 30, 29, 30, 30, 29, 30, 30, 29]],\n 2051: [\"2051-02-11\", [29, 30, 29, 30, 29, 29, 30, 30, 29, 30, 30, 30]],\n 2052: [\"2052-02-01\", [29, 30, 29, 29, 30, 29, 29, 30, -29, 30, 30, 30, 29]],\n 2053: [\"2053-02-18\", [30, 30, 29, 29, 30, 29, 29, 30, 29, 30, 30, 30]],\n 2054: [\"2054-02-08\", [29, 30, 30, 29, 29, 30, 29, 29, 30, 29, 30, 30]],\n 2055: [\"2055-01-28\", [29, 30, 30, 29, 30, 29, -30, 29, 29, 30, 29, 30, 29]],\n 2056: [\"2056-02-15\", [30, 30, 29, 30, 30, 29, 30, 29, 29, 30, 29, 30]],\n 2057: [\"2057-02-04\", [29, 30, 29, 30, 30, 29, 30, 29, 30, 29, 30, 29]],\n 2058: [\"2058-01-24\", [30, 29, 30, 29, -30, 29, 30, 30, 29, 30, 29, 30, 29]],\n 2059: [\"2059-02-12\", [30, 29, 30, 29, 30, 29, 30, 29, 30, 30, 29, 30]],\n 2060: [\"2060-02-02\", [29, 30, 29, 30, 29, 29, 30, 29, 30, 30, 30, 29]],\n 2061: [\"2061-01-21\", [30, 30, 29, -29, 30, 29, 29, 30, 29, 30, 30, 30, 29]],\n 2062: [\"2062-02-09\", [30, 30, 29, 29, 30, 29, 29, 30, 29, 30, 29, 30]],\n 2063: [\"2063-01-29\", [30, 30, 29, 30, 29, 30, 29, -29, 30, 29, 30, 29, 30]],\n 2064: [\"2064-02-17\", [30, 30, 29, 30, 29, 30, 29, 29, 30, 29, 30, 29]],\n 2065: [\"2065-02-05\", [30, 30, 29, 30, 30, 29, 29, 30, 29, 30, 29, 30]],\n 2066: [\"2066-01-26\", [29, 30, 29, 30, 30, -29, 30, 29, 30, 29, 30, 29, 30]],\n 2067: [\"2067-02-14\", [29, 30, 29, 30, 29, 30, 30, 29, 30, 29, 30, 29]],\n 2068: [\"2068-02-03\", [30, 29, 30, 29, 29, 30, 30, 29, 30, 30, 29, 30]],\n 2069: [\"2069-01-23\", [29, 30, 29, 30, -29, 29, 30, 29, 30, 30, 30, 29, 30]],\n 2070: [\"2070-02-11\", [29, 30, 29, 30, 29, 29, 30, 29, 30, 29, 30, 30]],\n 2071: [\"2071-01-31\", [30, 29, 30, 29, 30, 29, 29, 30, -29, 30, 29, 30, 30]],\n 2072: [\"2072-02-19\", [30, 29, 30, 29, 30, 29, 29, 30, 29, 29, 30, 30]],\n 2073: [\"2073-02-07\", [30, 29, 30, 30, 29, 30, 29, 29, 30, 29, 29, 30]],\n 2074: [\"2074-01-27\", [30, 29, 30, 30, 29, 30, -29, 30, 29, 30, 29, 30, 29]],\n 2075: [\"2075-02-15\", [30, 29, 30, 29, 30, 30, 29, 30, 29, 30, 29, 30]],\n 2076: [\"2076-02-05\", [29, 30, 29, 30, 29, 30, 29, 30, 30, 29, 30, 29]],\n 2077: [\"2077-01-24\", [30, 29, 30, 29, -29, 30, 29, 30, 30, 30, 29, 30, 29]],\n 2078: [\"2078-02-12\", [30, 29, 30, 29, 29, 30, 29, 30, 29, 30, 30, 30]],\n 2079: [\"2079-02-02\", [29, 30, 29, 30, 29, 29, 30, 29, 30, 29, 30, 30]],\n 2080: [\"2080-01-22\", [30, 29, 30, -29, 30, 29, 29, 29, 30, 29, 30, 30, 30]],\n 2081: [\"2081-02-09\", [29, 30, 30, 29, 30, 29, 29, 30, 29, 29, 30, 30]],\n 2082: [\"2082-01-29\", [29, 30, 30, 29, 30, 29, 30, -29, 30, 29, 29, 30, 30]],\n 2083: [\"2083-02-17\", [29, 30, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29]],\n 2084: [\"2084-02-06\", [30, 29, 30, 29, 30, 30, 29, 30, 29, 30, 29, 30]],\n 2085: [\"2085-01-26\", [29, 29, 30, 29, 30, -30, 29, 30, 30, 29, 30, 29, 30]],\n 2086: [\"2086-02-14\", [29, 29, 30, 29, 30, 29, 30, 30, 29, 30, 30, 29]],\n 2087: [\"2087-02-03\", [30, 29, 30, 29, 29, 30, 29, 30, 29, 30, 30, 30]],\n 2088: [\"2088-01-24\", [29, 30, 29, 30, -29, 29, 29, 30, 29, 30, 30, 30, 29]],\n 2089: [\"2089-02-10\", [30, 30, 29, 30, 29, 29, 29, 30, 29, 30, 30, 29]],\n 2090: [\"2090-01-30\", [30, 30, 30, 29, 30, 29, 29, 30, -29, 29, 30, 29, 30]],\n 2091: [\"2091-02-18\", [30, 30, 29, 30, 29, 30, 29, 30, 29, 29, 30, 29]],\n 2092: [\"2092-02-07\", [30, 30, 29, 30, 30, 29, 30, 29, 30, 29, 29, 30]],\n 2093: [\"2093-01-27\", [29, 30, 29, 30, 30, 29, -30, 30, 29, 30, 29, 30, 29]],\n 2094: [\"2094-02-15\", [29, 30, 29, 30, 29, 30, 30, 29, 30, 30, 29, 30]],\n 2095: [\"2095-02-05\", [29, 29, 30, 29, 30, 29, 30, 29, 30, 30, 30, 29]],\n 2096: [\"2096-01-25\", [30, 29, 30, 29, -29, 30, 29, 29, 30, 30, 30, 29, 30]],\n 2097: [\"2097-02-12\", [30, 29, 30, 29, 29, 29, 30, 29, 30, 30, 29, 30]],\n 2098: [\"2098-02-01\", [30, 30, 29, 30, 29, 29, 29, 30, 29, 30, 29, 30]],\n 2099: [\"2099-01-21\", [30, 30, -29, 30, 29, 30, 29, 29, 30, 29, 30, 29, 30]],\n // END YEARS\n};\n\n/** Civil date at an instant in Vietnam's modern time zone, regardless of host settings. */\nexport function vietnamDate(instant = new Date()): string {\n return new Date(instant.valueOf() + 7 * 3_600_000).toISOString().slice(0, 10);\n}\n\nfunction requireSupported(iso: string) {\n if (!/^\\d{4}-\\d{2}-\\d{2}$/.test(iso) || iso < LUNAR_MIN || iso > LUNAR_MAX) {\n throw new RangeError(\n \"Expected a Gregorian date from \" + LUNAR_MIN + \" through \" + LUNAR_MAX,\n );\n }\n const time = Date.parse(iso);\n if (\n !Number.isFinite(time) ||\n new Date(time).toISOString().slice(0, 10) !== iso\n ) {\n throw new RangeError(\"Invalid Gregorian date\");\n }\n return time;\n}\n\nexport function gregorianToLunar(iso: string): LunarDate {\n const time = requireSupported(iso);\n const solarYear = Number(iso.slice(0, 4));\n const year = iso < years[solarYear]![0] ? solarYear - 1 : solarYear;\n const [tet, months] = years[year]!;\n let offset = (time - Date.parse(tet)) / millisecondsPerDay;\n let month = 0;\n for (const length of months) {\n if (length > 0) month++;\n if (offset < Math.abs(length))\n return { year, month, day: offset + 1, leap: length < 0 };\n offset -= Math.abs(length);\n }\n throw new RangeError(\"Date exceeds the lunar year\");\n}\n\nexport function lunarToGregorian(lunar: LunarDate): string {\n const row = years[lunar.year];\n if (\n !row ||\n !Number.isInteger(lunar.year) ||\n !Number.isInteger(lunar.day) ||\n lunar.day < 1\n ) {\n throw new RangeError(\"Invalid lunar date\");\n }\n let month = 0;\n let offset = 0;\n for (const length of row[1]) {\n if (length > 0) month++;\n if (month === lunar.month && length < 0 === lunar.leap) {\n if (lunar.day > Math.abs(length))\n throw new RangeError(\"Day exceeds the lunar month\");\n const time =\n Date.parse(row[0]) + (offset + lunar.day - 1) * millisecondsPerDay;\n const iso = new Date(time).toISOString().slice(0, 10);\n requireSupported(iso);\n return iso;\n }\n offset += Math.abs(length);\n }\n throw new RangeError(\"Lunar month does not occur in this year\");\n}\n"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"path": "lib/state.ts",
|
|
29
|
+
"type": "registry:file",
|
|
30
|
+
"target": "@components/vnui/lib/state.ts",
|
|
31
|
+
"content": "\"use client\";\nimport { useState } from \"react\";\nexport type ValueProps<T> = {\n value?: T;\n defaultValue?: T;\n onValueChange?: (value: T) => void;\n className?: string;\n label?: string;\n name?: string;\n disabled?: boolean;\n};\nexport function useValue<T>(\n props: ValueProps<T>,\n fallback: T,\n): [T, (v: T) => void] {\n const [local, setLocal] = useState<T>(\n props.defaultValue === undefined ? fallback : props.defaultValue,\n );\n return [\n props.value === undefined ? local : props.value,\n (v: T) => {\n if (props.value === undefined) setLocal(v);\n props.onValueChange?.(v);\n },\n ];\n}\n"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"path": "components/styles.css",
|
|
35
|
+
"type": "registry:file",
|
|
36
|
+
"target": "@components/vnui/components/styles.css",
|
|
37
|
+
"content": ".vn-bank-symbol {\n font: 600 0.7rem/1.2 system-ui;\n letter-spacing: 0.02em;\n color: var(--vn-ink, CanvasText);\n padding: 3px 5px;\n margin-left: 0.7rem;\n border: 1px solid var(--vn-border, #888);\n border-radius: 3px;\n}\n.vn-bank-symbol img {\n object-fit: contain;\n}\n.vn-lunar-fields {\n display: grid;\n grid-template-columns: 1fr 1fr 1.4fr;\n gap: 0.5rem;\n}\n.vn-field .vn-apply {\n justify-self: start;\n border: 1px solid var(--vn-border, #777);\n border-radius: 4px;\n padding: 5px 10px;\n font-size: 0.82rem;\n background: var(--vn-input, Canvas);\n color: inherit;\n cursor: pointer;\n}\n.vn-stack,\n.vn-field,\n.vn-qr {\n display: grid;\n gap: 0.55rem;\n min-width: 0;\n}\n.vn-stack {\n gap: 1rem;\n}\n.vn-field label,\n.vn-qr figcaption {\n font: 500 0.81rem/1.5 var(--font-geist-sans, system-ui);\n color: inherit;\n}\n.vn-field input:not([type=\"hidden\"]):not([type=\"checkbox\"]),\n.vn-entry {\n border: 1px solid var(--vn-border, #747474);\n background: var(--vn-input, Canvas);\n color: var(--vn-ink, CanvasText);\n border-radius: 6px;\n min-width: 0;\n width: 100%;\n box-sizing: border-box;\n font: 400 0.91rem/1.3 var(--font-geist-mono, monospace);\n height: 42px;\n padding: 0 0.8rem;\n}\n.vn-lunar-leap {\n display: inline-flex;\n align-items: center;\n gap: 0.5rem;\n justify-self: start;\n font-size: 0.875rem;\n cursor: pointer;\n}\n.vn-field .vn-lunar-leap input[type=\"checkbox\"] {\n width: 1rem;\n height: 1rem;\n margin: 0;\n padding: 0;\n accent-color: var(--vn-focus, #67ab94);\n}\n.vn-entry {\n display: flex;\n align-items: center;\n padding: 0;\n overflow: hidden;\n}\n.vn-entry input:not([type=\"hidden\"]) {\n border: 0;\n background: transparent;\n flex: 1;\n outline: none;\n}\n.vn-entry:focus-within,\n.vn-field > input:focus-visible {\n outline: 2px solid var(--vn-focus, #67ab94);\n outline-offset: 2px;\n}\n.vn-field small,\n.vn-qr small {\n color: var(--vn-error, #e08a85);\n}\n.vn-unit,\n.vn-chevron {\n padding: 0 0.8rem;\n color: var(--muted, inherit);\n}\n.vn-country {\n display: flex;\n gap: 0.4rem;\n align-items: center;\n font: 500 0.75rem system-ui;\n margin-left: 0.75rem;\n padding-right: 0.7rem;\n border-right: 1px solid var(--vn-border, #777);\n}\n.vn-country i {\n font: normal 11px/13px sans-serif;\n color: #ffde78;\n background: #b84244;\n padding: 0 3px;\n border-radius: 2px;\n}\n.vn-combo {\n position: relative;\n}\n.vn-options {\n position: absolute;\n z-index: 12;\n top: 100%;\n margin-top: 4px;\n left: 0;\n right: 0;\n background: var(--vn-input, Canvas);\n color: var(--vn-ink, CanvasText);\n border: 1px solid var(--vn-border, #777);\n border-radius: 6px;\n padding: 4px;\n max-height: 220px;\n overflow: auto;\n text-align: left;\n}\n.vn-options > div {\n padding: 0.5rem;\n cursor: pointer;\n font-size: 0.875rem;\n}\n.vn-options > [data-active=\"true\"],\n.vn-options > div:hover {\n background: var(--vn-highlight, Highlight);\n color: var(--vn-highlight-ink, HighlightText);\n}\n.vn-matches {\n list-style: none;\n padding: 0;\n margin: 0;\n}\n.vn-matches li {\n padding: 0.45rem 0;\n}\n.vn-matches mark {\n background: #b3e3c7;\n color: #173222;\n}\n.vn-qr {\n justify-items: start;\n margin: 0;\n}\n.vn-qr img {\n max-width: 100%;\n height: auto;\n}\n.vn-qr a {\n margin-right: 1rem;\n text-decoration: underline;\n font-size: 0.85rem;\n}\n.vn-field output {\n font-family: monospace;\n font-size: 0.9rem;\n}\n"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"path": "components/styles.css.d.ts",
|
|
41
|
+
"type": "registry:file",
|
|
42
|
+
"target": "@components/vnui/components/styles.css.d.ts",
|
|
43
|
+
"content": "/** Side-effect stylesheet import for strict TypeScript consumers. */\nexport {};\n"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"path": "LICENSE",
|
|
47
|
+
"type": "registry:file",
|
|
48
|
+
"target": "@components/vnui/LICENSE",
|
|
49
|
+
"content": "MIT License\r\n\r\nCopyright (c) 2026 Ngo Dinh Nam\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE.\r\n"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "phone-input",
|
|
4
|
+
"type": "registry:block",
|
|
5
|
+
"title": "Phone Input",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"devDependencies": [],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "components/phone-input.tsx",
|
|
11
|
+
"type": "registry:file",
|
|
12
|
+
"target": "@components/vnui/components/phone-input.tsx",
|
|
13
|
+
"content": "\"use client\";\nimport { useId, useState, type Ref } from \"react\";\nimport { formatPhone, normalizePhone } from \"../lib/phone\";\nimport { useValue, type ValueProps } from \"../lib/state\";\nimport { useValidity } from \"../lib/validity\";\nimport \"./styles.css\";\nexport function PhoneInput({\n ref,\n ...p\n}: ValueProps<string> & {\n validate?: (text: string) => boolean;\n onNormalizedChange?: (v: string | null) => void;\n ref?: Ref<HTMLInputElement>;\n onBlur?: () => void;\n}) {\n const [v, set] = useValue(p, \"\");\n const [touched, touch] = useState(false);\n const id = useId();\n const message =\n v && !(p.validate ? p.validate(v) : normalizePhone(v))\n ? \"Enter a Vietnamese number starting with 0 or +84.\"\n : \"\";\n const input = useValidity(message, ref);\n const invalid = touched && !!message;\n return (\n <div className={\"vn-field \" + (p.className || \"\")}>\n <label htmlFor={id}>{p.label || \"Phone number\"}</label>\n <div className=\"vn-entry\">\n <span className=\"vn-country\">\n <i>★</i> VN\n </span>\n <input\n id={id}\n ref={input}\n onInvalid={() => touch(true)}\n type=\"tel\"\n autoComplete=\"tel\"\n name={p.name}\n disabled={p.disabled}\n placeholder=\"0912 345 678\"\n value={formatPhone(v)}\n onChange={(e) => {\n const next = e.target.value;\n set(next);\n p.onNormalizedChange?.(normalizePhone(next));\n }}\n onBlur={() => {\n touch(true);\n p.onBlur?.();\n }}\n aria-invalid={invalid}\n aria-describedby={invalid ? id + \"-err\" : undefined}\n />\n </div>\n {invalid && (\n <small id={id + \"-err\"} role=\"alert\">\n {message}\n </small>\n )}\n </div>\n );\n}\n"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"path": "lib/phone.ts",
|
|
17
|
+
"type": "registry:file",
|
|
18
|
+
"target": "@components/vnui/lib/phone.ts",
|
|
19
|
+
"content": "/** Consumer mobile and geographic numbers. Validation concerns shape only. */\nexport function normalizePhone(input: string): string | null {\n const compact = input.trim().replace(/[ ().-]/g, \"\");\n const national = compact.startsWith(\"+84\")\n ? compact.slice(3)\n : compact.startsWith(\"0\")\n ? compact.slice(1)\n : \"\";\n if (!/^(?:[35789]\\d{8}|2\\d{9})$/.test(national)) return null;\n return \"+84\" + national;\n}\n\n/** Preserve partial prefixes and invalid input so a caller can show useful feedback. */\nexport function formatPhone(input: string): string {\n const compact = input.trim().replace(/[ ().-]/g, \"\");\n if (!/^(?:0\\d*|\\+84\\d*)$/.test(compact)) return input;\n const international = compact.startsWith(\"+\");\n const national = compact.slice(international ? 3 : 1);\n const fixedLine = national.startsWith(\"2\");\n const first = fixedLine && /^(24|28)/.test(national) ? 2 : 3;\n const second = fixedLine && first === 2 ? 4 : 3;\n const groups = [\n national.slice(0, first),\n national.slice(first, first + second),\n national.slice(first + second),\n ].filter(Boolean);\n if (international) return [\"+84\", ...groups].join(\" \");\n return \"0\" + groups.join(\" \");\n}\n"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"path": "lib/state.ts",
|
|
23
|
+
"type": "registry:file",
|
|
24
|
+
"target": "@components/vnui/lib/state.ts",
|
|
25
|
+
"content": "\"use client\";\nimport { useState } from \"react\";\nexport type ValueProps<T> = {\n value?: T;\n defaultValue?: T;\n onValueChange?: (value: T) => void;\n className?: string;\n label?: string;\n name?: string;\n disabled?: boolean;\n};\nexport function useValue<T>(\n props: ValueProps<T>,\n fallback: T,\n): [T, (v: T) => void] {\n const [local, setLocal] = useState<T>(\n props.defaultValue === undefined ? fallback : props.defaultValue,\n );\n return [\n props.value === undefined ? local : props.value,\n (v: T) => {\n if (props.value === undefined) setLocal(v);\n props.onValueChange?.(v);\n },\n ];\n}\n"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"path": "lib/validity.ts",
|
|
29
|
+
"type": "registry:file",
|
|
30
|
+
"target": "@components/vnui/lib/validity.ts",
|
|
31
|
+
"content": "\"use client\";\nimport { useImperativeHandle, useLayoutEffect, useRef, type Ref } from \"react\";\n/** Keep native form submission and a form library's focus ref in sync with validation. */\nexport function useValidity(\n message: string,\n forwarded?: Ref<HTMLInputElement>,\n) {\n const input = useRef<HTMLInputElement>(null);\n useImperativeHandle(forwarded, () => input.current!, []);\n useLayoutEffect(() => {\n input.current?.setCustomValidity(message);\n }, [message]);\n return input;\n}\n"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"path": "components/styles.css",
|
|
35
|
+
"type": "registry:file",
|
|
36
|
+
"target": "@components/vnui/components/styles.css",
|
|
37
|
+
"content": ".vn-bank-symbol {\n font: 600 0.7rem/1.2 system-ui;\n letter-spacing: 0.02em;\n color: var(--vn-ink, CanvasText);\n padding: 3px 5px;\n margin-left: 0.7rem;\n border: 1px solid var(--vn-border, #888);\n border-radius: 3px;\n}\n.vn-bank-symbol img {\n object-fit: contain;\n}\n.vn-lunar-fields {\n display: grid;\n grid-template-columns: 1fr 1fr 1.4fr;\n gap: 0.5rem;\n}\n.vn-field .vn-apply {\n justify-self: start;\n border: 1px solid var(--vn-border, #777);\n border-radius: 4px;\n padding: 5px 10px;\n font-size: 0.82rem;\n background: var(--vn-input, Canvas);\n color: inherit;\n cursor: pointer;\n}\n.vn-stack,\n.vn-field,\n.vn-qr {\n display: grid;\n gap: 0.55rem;\n min-width: 0;\n}\n.vn-stack {\n gap: 1rem;\n}\n.vn-field label,\n.vn-qr figcaption {\n font: 500 0.81rem/1.5 var(--font-geist-sans, system-ui);\n color: inherit;\n}\n.vn-field input:not([type=\"hidden\"]):not([type=\"checkbox\"]),\n.vn-entry {\n border: 1px solid var(--vn-border, #747474);\n background: var(--vn-input, Canvas);\n color: var(--vn-ink, CanvasText);\n border-radius: 6px;\n min-width: 0;\n width: 100%;\n box-sizing: border-box;\n font: 400 0.91rem/1.3 var(--font-geist-mono, monospace);\n height: 42px;\n padding: 0 0.8rem;\n}\n.vn-lunar-leap {\n display: inline-flex;\n align-items: center;\n gap: 0.5rem;\n justify-self: start;\n font-size: 0.875rem;\n cursor: pointer;\n}\n.vn-field .vn-lunar-leap input[type=\"checkbox\"] {\n width: 1rem;\n height: 1rem;\n margin: 0;\n padding: 0;\n accent-color: var(--vn-focus, #67ab94);\n}\n.vn-entry {\n display: flex;\n align-items: center;\n padding: 0;\n overflow: hidden;\n}\n.vn-entry input:not([type=\"hidden\"]) {\n border: 0;\n background: transparent;\n flex: 1;\n outline: none;\n}\n.vn-entry:focus-within,\n.vn-field > input:focus-visible {\n outline: 2px solid var(--vn-focus, #67ab94);\n outline-offset: 2px;\n}\n.vn-field small,\n.vn-qr small {\n color: var(--vn-error, #e08a85);\n}\n.vn-unit,\n.vn-chevron {\n padding: 0 0.8rem;\n color: var(--muted, inherit);\n}\n.vn-country {\n display: flex;\n gap: 0.4rem;\n align-items: center;\n font: 500 0.75rem system-ui;\n margin-left: 0.75rem;\n padding-right: 0.7rem;\n border-right: 1px solid var(--vn-border, #777);\n}\n.vn-country i {\n font: normal 11px/13px sans-serif;\n color: #ffde78;\n background: #b84244;\n padding: 0 3px;\n border-radius: 2px;\n}\n.vn-combo {\n position: relative;\n}\n.vn-options {\n position: absolute;\n z-index: 12;\n top: 100%;\n margin-top: 4px;\n left: 0;\n right: 0;\n background: var(--vn-input, Canvas);\n color: var(--vn-ink, CanvasText);\n border: 1px solid var(--vn-border, #777);\n border-radius: 6px;\n padding: 4px;\n max-height: 220px;\n overflow: auto;\n text-align: left;\n}\n.vn-options > div {\n padding: 0.5rem;\n cursor: pointer;\n font-size: 0.875rem;\n}\n.vn-options > [data-active=\"true\"],\n.vn-options > div:hover {\n background: var(--vn-highlight, Highlight);\n color: var(--vn-highlight-ink, HighlightText);\n}\n.vn-matches {\n list-style: none;\n padding: 0;\n margin: 0;\n}\n.vn-matches li {\n padding: 0.45rem 0;\n}\n.vn-matches mark {\n background: #b3e3c7;\n color: #173222;\n}\n.vn-qr {\n justify-items: start;\n margin: 0;\n}\n.vn-qr img {\n max-width: 100%;\n height: auto;\n}\n.vn-qr a {\n margin-right: 1rem;\n text-decoration: underline;\n font-size: 0.85rem;\n}\n.vn-field output {\n font-family: monospace;\n font-size: 0.9rem;\n}\n"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"path": "components/styles.css.d.ts",
|
|
41
|
+
"type": "registry:file",
|
|
42
|
+
"target": "@components/vnui/components/styles.css.d.ts",
|
|
43
|
+
"content": "/** Side-effect stylesheet import for strict TypeScript consumers. */\nexport {};\n"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"path": "LICENSE",
|
|
47
|
+
"type": "registry:file",
|
|
48
|
+
"target": "@components/vnui/LICENSE",
|
|
49
|
+
"content": "MIT License\r\n\r\nCopyright (c) 2026 Ngo Dinh Nam\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE.\r\n"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|