Files
aurora-admin/site/examples/codeinput.json

39 lines
5.1 KiB
JSON
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"slug": "codeinput",
"mode": "single",
"curated": true,
"examples": [
{
"id": "codeinput-ex-1",
"title": "基础用法",
"titleSrc": "",
"desc": "",
"html": "<div class=\"kole-page\">\n <h2 class=\"kole-h2\">CodeInput 验证码输入</h2>\n <p class=\"kole-desc\">用于短信验证码、一次性口令(OTP)输入,支持自动跳转、退格回退与粘贴填充。</p>\n <div class=\"kole-demo\">\n <div class=\"kole-demo__title\">基础用法(6 位)</div>\n <div class=\"kole-code\" id=\"code1\" data-length=\"6\"></div>\n <div class=\"kole-code-tip\" id=\"code1-tip\"></div>\n </div>\n <div class=\"kole-demo\">\n <div class=\"kole-demo__title\">掩码模式 + 4 位</div>\n <div class=\"kole-code\" id=\"code2\" data-length=\"4\" data-masked=\"1\"></div>\n <div class=\"kole-code-tip\" id=\"code2-tip\"></div>\n </div>\n</div>",
"preview": {
"show": [
[
0
]
],
"hide": [],
"mode": "single"
},
"previewSafe": true,
"previewUnsafeReasons": [],
"source": "curated",
"code": {
"html": "<h2>CodeInput 验证码输入</h2>\n<p>用于短信验证码、一次性口令(OTP)输入,支持自动跳转、退格回退与粘贴填充。</p>\n<div>基础用法(6 位)</div>\n<div class=\"kole-code\" data-length=\"6\"></div>\n<div class=\"kole-code-tip\"></div>\n<div>掩码模式 + 4 位</div>\n<div class=\"kole-code\" data-length=\"4\" data-masked=\"1\"></div>\n<div class=\"kole-code-tip\"></div>",
"jsx": "import { useState } from 'react';\nimport { KoleCodeInput } from 'kole-ui/react';\n\nexport default function Demo() {\n const [code, setCode] = useState('');\n const [pin, setPin] = useState('');\n const tip6 = code.length === 6 ? '已输入完成:' + code : '';\n const tip4 = pin.length === 4 ? '已输入完成:' + pin : '';\n return (\n <>\n <KoleCodeInput value={code} length={6} onChange={setCode} tip={tip6} />\n <KoleCodeInput value={pin} length={4} masked onChange={setPin} tip={tip4} />\n </>\n );\n}",
"vue3": "<template>\n <KoleCodeInput v-model=\"code\" :length=\"6\" :tip=\"tip6\" />\n <KoleCodeInput v-model=\"pin\" :length=\"4\" masked :tip=\"tip4\" />\n</template>\n\n<script setup>\nimport { ref, computed } from 'vue';\nimport { KoleCodeInput } from 'kole-ui/vue3';\n\nconst code = ref('');\nconst pin = ref('');\nconst tip6 = computed(() => (code.value.length === 6 ? '已输入完成:' + code.value : ''));\nconst tip4 = computed(() => (pin.value.length === 4 ? '已输入完成:' + pin.value : ''));\n</script>",
"vue2": "<template>\n <div>\n <KoleCodeInput v-model=\"code\" :length=\"6\" :tip=\"tip6\" />\n <KoleCodeInput v-model=\"pin\" :length=\"4\" masked :tip=\"tip4\" />\n </div>\n</template>\n\n<script>\nimport { KoleCodeInput } from 'kole-ui/vue2';\n\nexport default {\n components: { KoleCodeInput },\n data() {\n return { code: '', pin: '' };\n },\n computed: {\n tip6() {\n return this.code.length === 6 ? '已输入完成:' + this.code : '';\n },\n tip4() {\n return this.pin.length === 4 ? '已输入完成:' + this.pin : '';\n }\n }\n};\n</script>",
"tsx": "import { useState } from 'react';\nimport { KoleCodeInput } from 'kole-ui/react';\n\nexport default function Demo(): JSX.Element {\n const [code, setCode] = useState<string>('');\n const [pin, setPin] = useState<string>('');\n const tip6 = code.length === 6 ? '已输入完成:' + code : '';\n const tip4 = pin.length === 4 ? '已输入完成:' + pin : '';\n return (\n <>\n <KoleCodeInput value={code} length={6} onChange={setCode} tip={tip6} />\n <KoleCodeInput value={pin} length={4} masked onChange={setPin} tip={tip4} />\n </>\n );\n}",
"vue3ts": "<template>\n\n <KoleCodeInput v-model=\"code\" :length=\"6\" :tip=\"tip6\" />\n <KoleCodeInput v-model=\"pin\" :length=\"4\" masked :tip=\"tip4\" />\n</template>\n\n<script setup lang=\"ts\">\nimport { KoleCodeInput } from 'kole-ui/vue3';\n\nconst code = ref<string>('');\nconst pin = ref<string>('');\nconst tip6 = computed(() => (code.value.length === 6 ? '已输入完成:' + code.value : ''));\nconst tip4 = computed(() => (pin.value.length === 4 ? '已输入完成:' + pin.value : ''));\n</script>",
"vue2ts": "<template>\n\n <div>\n <KoleCodeInput v-model=\"code\" :length=\"6\" :tip=\"tip6\" />\n <KoleCodeInput v-model=\"pin\" :length=\"4\" masked :tip=\"tip4\" />\n </div>\n</template>\n\n<script lang=\"ts\">\nimport Vue from 'vue';\nimport { KoleCodeInput } from 'kole-ui/vue2';\n\nexport default {\n components: { KoleCodeInput },\n data(): Record<string, unknown> {\n return { code: '', pin: '' };\n },\n computed: {\n tip6(): void {\n return this.code.length === 6 ? '已输入完成:' + this.code : '';\n },\n tip4(): void {\n return this.pin.length === 4 ? '已输入完成:' + this.pin : '';\n }\n }\n};\n</script>"
},
"notes": [
"依据 frameworks/CodeInput.html:17 data-length=6 与 :23 data-length=4 data-masked=1 两个实例,以及 :99「已输入完成:」提示文案;prop 名取自 frameworks/CodeInput.jsx:10-17(value/length/masked/tip)"
]
}
]
}