From 1bd4e9da19126731e3c87686c2335a4c7a643bb6 Mon Sep 17 00:00:00 2001 From: Shigma Date: Tue, 2 May 2023 01:30:42 +0800 Subject: [PATCH] chore: remove docs --- .github/workflows/build.yaml | 1 + docs/.vuepress/client.ts | 59 -------- docs/.vuepress/config.ts | 80 ---------- docs/.vuepress/example.vue | 149 ------------------- docs/.vuepress/json.vue | 46 ------ docs/.vuepress/layout.vue | 17 --- docs/.vuepress/sidebar.vue | 67 --------- docs/.vuepress/styles/code.scss | 35 ----- docs/.vuepress/styles/element.scss | 46 ------ docs/.vuepress/styles/index.scss | 230 ----------------------------- docs/.vuepress/theme.ts | 16 -- docs/.vuepress/tsconfig.json | 18 --- docs/atomic/bitset.md | 22 --- docs/atomic/boolean.md | 17 --- docs/atomic/date.md | 28 ---- docs/atomic/number.md | 20 --- docs/atomic/string.md | 29 ---- docs/composite/array.md | 17 --- docs/composite/dict.md | 17 --- docs/composite/intersect.md | 31 ---- docs/composite/object.md | 25 ---- docs/composite/transform.md | 23 --- docs/composite/tuple.md | 19 --- docs/composite/union-arbitrary.md | 37 ----- docs/composite/union-select.md | 27 ---- docs/composite/union-tagged-1.md | 43 ------ docs/composite/union-tagged-2.md | 37 ----- docs/index.md | 1 - docs/meta/default.md | 19 --- docs/meta/description.md | 19 --- docs/meta/hidden.md | 19 --- docs/meta/required.md | 17 --- docs/meta/role.md | 38 ----- 33 files changed, 1 insertion(+), 1268 deletions(-) delete mode 100644 docs/.vuepress/client.ts delete mode 100644 docs/.vuepress/config.ts delete mode 100644 docs/.vuepress/example.vue delete mode 100644 docs/.vuepress/json.vue delete mode 100644 docs/.vuepress/layout.vue delete mode 100644 docs/.vuepress/sidebar.vue delete mode 100644 docs/.vuepress/styles/code.scss delete mode 100644 docs/.vuepress/styles/element.scss delete mode 100644 docs/.vuepress/styles/index.scss delete mode 100644 docs/.vuepress/theme.ts delete mode 100644 docs/.vuepress/tsconfig.json delete mode 100644 docs/atomic/bitset.md delete mode 100644 docs/atomic/boolean.md delete mode 100644 docs/atomic/date.md delete mode 100644 docs/atomic/number.md delete mode 100644 docs/atomic/string.md delete mode 100644 docs/composite/array.md delete mode 100644 docs/composite/dict.md delete mode 100644 docs/composite/intersect.md delete mode 100644 docs/composite/object.md delete mode 100644 docs/composite/transform.md delete mode 100644 docs/composite/tuple.md delete mode 100644 docs/composite/union-arbitrary.md delete mode 100644 docs/composite/union-select.md delete mode 100644 docs/composite/union-tagged-1.md delete mode 100644 docs/composite/union-tagged-2.md delete mode 120000 docs/index.md delete mode 100644 docs/meta/default.md delete mode 100644 docs/meta/description.md delete mode 100644 docs/meta/hidden.md delete mode 100644 docs/meta/required.md delete mode 100644 docs/meta/role.md diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a8cbec5..80f3b45 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -34,6 +34,7 @@ jobs: name: codecov deploy: + if: ${{ false }} runs-on: ubuntu-latest steps: diff --git a/docs/.vuepress/client.ts b/docs/.vuepress/client.ts deleted file mode 100644 index 2bf8485..0000000 --- a/docs/.vuepress/client.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { defineClientConfig } from '@vuepress/client' -import Markdown from 'marked-vue' -import Form from 'schemastery-vue' -import Schema from 'schemastery' -import { - ElButton, - ElCheckbox, - ElDropdown, - ElDropdownItem, - ElDropdownMenu, - ElInput, - ElInputNumber, - ElRadio, - ElScrollbar, - ElSelect, - ElSlider, - ElSwitch, - ElDatePicker, - ElTimePicker, -} from 'element-plus' - -// import 'element-plus/es/components/button/style/css' -// import 'element-plus/es/components/checkbox/style/css' -// import 'element-plus/es/components/dropdown/style/css' -// import 'element-plus/es/components/dropdown-item/style/css' -// import 'element-plus/es/components/dropdown-menu/style/css' -// import 'element-plus/es/components/input/style/css' -// import 'element-plus/es/components/input-number/style/css' -// import 'element-plus/es/components/radio/style/css' -// import 'element-plus/es/components/scrollbar/style/css' -// import 'element-plus/es/components/select/style/css' -// import 'element-plus/es/components/slider/style/css' -// import 'element-plus/es/components/switch/style/css' -import 'element-plus/dist/index.css' -import './styles/index.scss' - -globalThis.Schema = Schema - -export default defineClientConfig({ - enhance({ app, router, siteData }) { - app.use(ElButton) - app.use(ElCheckbox) - app.use(ElDropdown) - app.use(ElDropdownItem) - app.use(ElDropdownMenu) - app.use(ElInput) - app.use(ElInputNumber) - app.use(ElRadio) - app.use(ElScrollbar) - app.use(ElSelect) - app.use(ElSlider) - app.use(ElSwitch) - app.use(ElDatePicker) - app.use(ElTimePicker) - app.component('k-markdown', Markdown) - app.use(Form) - }, - setup() {}, -}) diff --git a/docs/.vuepress/config.ts b/docs/.vuepress/config.ts deleted file mode 100644 index d8ccb11..0000000 --- a/docs/.vuepress/config.ts +++ /dev/null @@ -1,80 +0,0 @@ -import { viteBundler, defineUserConfig } from 'vuepress' -import { shikiPlugin } from '@vuepress/plugin-shiki' -import { resolve } from 'path' -import theme from './theme' - -export default defineUserConfig({ - port: 8004, - title: 'Schemastery', - base: '/schemastery/', - dest: resolve(__dirname, 'dist/schemastery'), - - theme: theme({ - navbar: false, - sidebar: [{ - text: 'Introduction', - link: '/', - }, { - text: 'Meta Properties', - children: [ - '/meta/description.md', - '/meta/required.md', - '/meta/default.md', - '/meta/role.md', - '/meta/hidden.md', - ], - }, { - text: 'Atomic Types', - children: [ - '/atomic/number.md', - '/atomic/string.md', - '/atomic/boolean.md', - '/atomic/date.md', - '/atomic/bitset.md', - ], - }, { - text: 'Composite Types', - children: [ - '/composite/array.md', - '/composite/dict.md', - '/composite/tuple.md', - '/composite/object.md', - '/composite/intersect.md', - '/composite/union-select.md', - '/composite/union-arbitrary.md', - '/composite/union-tagged-1.md', - '/composite/union-tagged-2.md', - '/composite/transform.md', - ], - }], - themePlugins: { - git: false, - }, - }), - - markdown: { - headers: false, - code: { - lineNumbers: false, - }, - }, - - plugins: [ - shikiPlugin({ - theme: 'one-dark-pro', - }), - ], - - bundler: viteBundler({ - viteOptions: { - resolve: { - dedupe: ['vue'], - }, - server: { - fs: { - strict: false, - }, - }, - }, - }), -}) diff --git a/docs/.vuepress/example.vue b/docs/.vuepress/example.vue deleted file mode 100644 index ce61361..0000000 --- a/docs/.vuepress/example.vue +++ /dev/null @@ -1,149 +0,0 @@ - - - - - diff --git a/docs/.vuepress/json.vue b/docs/.vuepress/json.vue deleted file mode 100644 index 93117d8..0000000 --- a/docs/.vuepress/json.vue +++ /dev/null @@ -1,46 +0,0 @@ - - - diff --git a/docs/.vuepress/layout.vue b/docs/.vuepress/layout.vue deleted file mode 100644 index b1e4c09..0000000 --- a/docs/.vuepress/layout.vue +++ /dev/null @@ -1,17 +0,0 @@ - - - diff --git a/docs/.vuepress/sidebar.vue b/docs/.vuepress/sidebar.vue deleted file mode 100644 index d673974..0000000 --- a/docs/.vuepress/sidebar.vue +++ /dev/null @@ -1,67 +0,0 @@ - - - - - diff --git a/docs/.vuepress/styles/code.scss b/docs/.vuepress/styles/code.scss deleted file mode 100644 index 331bf07..0000000 --- a/docs/.vuepress/styles/code.scss +++ /dev/null @@ -1,35 +0,0 @@ -@mixin token-color($name, $color) { - :root.dark { - --shiki-token-#{$name}: #{$color}; - } - - span[style="color:#{$color};"] { - color: var(--shiki-token-#{$name}) !important; - } -} - -// color from One Dark Pro -@include token-color(text, #ABB2BF); -@include token-color(constant, #E5C07B); -@include token-color(number, #D19A66); -@include token-color(string, #98C379); -@include token-color(comment, #7F848E); -@include token-color(keyword, #C678DD); -@include token-color(parameter, #E06C75); -@include token-color(function, #61AFEF); -@include token-color(operator, #56B6C2); -@include token-color(punctuation, #ABB2BF); - -:root { - // modified from GitHub Light Default - --shiki-token-text: #000000; - --shiki-token-constant: #005CC5; - --shiki-token-number: #005CC5; - --shiki-token-string: #22863A; - --shiki-token-comment: #6A737D; - --shiki-token-keyword: #D73A49; - --shiki-token-parameter: #E36209; - --shiki-token-function: #6F42C1; - --shiki-token-operator: #D73A49; - --shiki-token-punctuation: #032F62; -} diff --git a/docs/.vuepress/styles/element.scss b/docs/.vuepress/styles/element.scss deleted file mode 100644 index 6ed33ef..0000000 --- a/docs/.vuepress/styles/element.scss +++ /dev/null @@ -1,46 +0,0 @@ -.el-dropdown__popper { - --el-dropdown-menuItem-hover-fill: var(--c-bg-soft); - --el-dropdown-menuItem-hover-color: var(--el-color-primary); -} - -.el-dropdown-menu__item.is-disabled { - pointer-events: none; -} - -.el-dropdown-menu__item--divided { - &:first-child, &:last-child { - display: none; - } -} - -.el-input .k-icon { - height: 0.75rem; -} - -.el-input__wrapper, -.el-input-number__decrease, -.el-input-number__increase, -.el-checkbox__label { - transition: var(--color-transition); -} - -.el-input__prefix-inner, .el-input__suffix-inner { - align-items: center; -} - -.el-radio { - height: 1.2rem; -} - -.el-radio__label { - --el-color-primary: var(--active); - padding-top: 1px; -} - -.el-scrollbar__bar { - z-index: 500; -} - -html.dark .el-switch { - --el-switch-off-color: #72767d; -} diff --git a/docs/.vuepress/styles/index.scss b/docs/.vuepress/styles/index.scss deleted file mode 100644 index 3b45626..0000000 --- a/docs/.vuepress/styles/index.scss +++ /dev/null @@ -1,230 +0,0 @@ -@import './code.scss'; -@import './element.scss'; - -:root { - --white: #ffffff; - --white-soft: #f9f9f9; - --white-mute: #f1f1f1; - --black: #1a1a1a; - --black-pure: #000000; - --black-soft: #242424; - --black-mute: #2f2f2f; - --gray: #8e8e8e; - --gray-light-1: #aeaeae; - --gray-light-2: #c7c7c7; - --gray-light-3: #d1d1d1; - --gray-light-4: #e5e5e5; - --gray-light-5: #f2f2f2; - --gray-dark-1: #636363; - --gray-dark-2: #484848; - --gray-dark-3: #3a3a3a; - --gray-dark-4: #282828; - --gray-dark-5: #202020; - --c-divider-light-1: rgba(60, 60, 60, .29); - --c-divider-light-2: rgba(60, 60, 60, .12); - --c-divider-dark-1: rgba(84, 84, 84, .65); - --c-divider-dark-2: rgba(84, 84, 84, .48); - --c-text-light-1: var(--c-indigo); - --c-text-light-2: rgba(60, 60, 60, .7); - --c-text-light-3: rgba(60, 60, 60, .33); - --c-text-light-4: rgba(60, 60, 60, .18); - --c-text-dark-1: rgba(255, 255, 255, .87); - --c-text-dark-2: rgba(235, 235, 235, .6); - --c-text-dark-3: rgba(235, 235, 235, .38); - --c-text-dark-4: rgba(235, 235, 235, .18); - --c-indigo: #213547; - --c-indigo-soft: #476582; - --c-indigo-light: #aac8e4; - --c-indigo-lighter: #c9def1; - --c-indigo-dark: #1d2f3f; - --c-indigo-darker: #14212e; - --green: #42b883; - --green-light: #42d392; - --green-lighter: #35eb9a; - --green-dark: #33a06f; - --green-darker: #155f3e; - --green-dimm-1: rgba(66, 184, 131, .5); - --green-dimm-2: rgba(66, 184, 131, .25); - --green-dimm-3: rgba(66, 184, 131, .05); - --yellow: #ffc517; - --yellow-light: #fcd253; - --yellow-lighter: #fcfc7c; - --yellow-dark: #e0ad15; - --yellow-darker: #ad850e; - --yellow-dimm-1: rgba(255, 197, 23, .5); - --yellow-dimm-2: rgba(255, 197, 23, .25); - --yellow-dimm-3: rgba(255, 197, 23, .05); - --red: #ed3c50; - --red-light: #f54e82; - --red-lighter: #fd1d7c; - --red-dark: #cd2d3f; - --red-darker: #ab2131; - --red-dimm-1: rgba(237, 60, 80, .5); - --red-dimm-2: rgba(237, 60, 80, .25); - --red-dimm-3: rgba(237, 60, 80, .05); - --brand: #646cff; - --brand-light: #747bff; - --brand-lighter: #9499ff; - --brand-lightest: #bcc0ff; - --brand-dark: #535bf2; - --brand-darker: #454ce1; - --brand-dimm: rgba(44, 46, 82, 0.08); - --color-transition: color 0.3s ease, border-color 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease; - - --sidebar-width: 240px; - --sidebar-width-mobile: 240px; -} - -:root { - --c-bg: var(--white-mute); - --c-bg-soft: var(--white-soft); - --c-bg-mute: var(--white); - --c-divider: var(--c-divider-light-1); - --c-divider-light: var(--c-divider-light-2); - --c-divider-inverse: var(--c-divider-dark-1); - --c-divider-inverse-light: var(--c-divider-dark-2); - --c-text-1: var(--c-text-light-1); - --c-text-2: var(--c-text-light-2); - --c-text-3: var(--c-text-light-3); - --c-text-4: var(--c-text-light-4); - --c-text-inverse-1: var(--c-text-dark-1); - --c-text-inverse-2: var(--c-text-dark-2); - --c-text-inverse-3: var(--c-text-dark-3); - --c-text-inverse-4: var(--c-text-dark-4); - --c-text-code: var(--c-indigo-soft); - --c-brand: var(--brand); - --c-brand-dark: var(--brand-darker); - --c-brand-light: var(--brand-lighter); - - // override vuepress - --c-bg-sidebar: var(--c-bg); - --c-border: var(--c-divider-light); - --c-border-dark: var(--c-divider); - --c-text: var(--c-text-1); - --code-bg-color: var(--c-bg-alt); -} - -html.dark { - --c-bg: var(--black); - --c-bg-soft: var(--black-soft); - --c-bg-mute: var(--black-mute); - --c-divider: var(--c-divider-dark-1); - --c-divider-light: var(--c-divider-dark-2); - --c-divider-inverse: var(--c-divider-light-1); - --c-divider-inverse-light: var(--c-divider-light-2); - --c-text-1: var(--c-text-dark-1); - --c-text-2: var(--c-text-dark-2); - --c-text-3: var(--c-text-dark-3); - --c-text-4: var(--c-text-dark-4); - --c-text-inverse-1: var(--c-text-light-1); - --c-text-inverse-2: var(--c-text-light-2); - --c-text-inverse-3: var(--c-text-light-3); - --c-text-inverse-4: var(--c-text-light-4); - --c-text-code: var(--c-indigo-lighter); - --c-brand: var(--brand-light); - --c-brand-dark: var(--brand-darker); - --c-brand-light: var(--brand-lighter); - - // override vuepress - --c-border: var(--c-divider-light); - --c-border-dark: var(--c-divider); - --c-text: var(--c-text-1); - --code-bg-color: var(--c-bg-alt); -} - -html, body { - background-color: var(--c-bg-soft); -} - -:root { - --vp-shadow-1: 0 1px 2px rgba(0, 0, 0, .04), 0 1px 2px rgba(0, 0, 0, .06); - --vp-shadow-2: 0 3px 12px rgba(0, 0, 0, .07), 0 1px 4px rgba(0, 0, 0, .07); - --vp-shadow-3: 0 12px 32px rgba(0, 0, 0, .1), 0 2px 6px rgba(0, 0, 0, .08); - --vp-shadow-4: 0 14px 44px rgba(0, 0, 0, .12), 0 3px 9px rgba(0, 0, 0, .12); - --vp-shadow-5: 0 18px 56px rgba(0, 0, 0, .16), 0 4px 12px rgba(0, 0, 0, .16); -} - -:root { - // override element - --el-text-color-regular: var(--fg1); - --el-text-color-primary: var(--fg3); - --el-input-text-color: var(--fg1); - --el-border-color: var(--c-border); - --el-border-color-hover: var(--c-brand-dark); - --el-border-color-base: var(--c-divider); - --el-border-color-light: var(--c-divider-light); - --el-border-color-lighter: var(--c-divider-light); - --el-border-color-extra-light: var(--c-divider-light); - --el-color-primary: var(--brand); - --el-color-success: var(--green); - --el-color-warning: var(--yellow); - --el-color-error: var(--red); - --el-color-white: var(--white); - --el-color-black: var(--fg1); - --el-bg-color: var(--bg0); - --el-fill-color-light: var(--c-bg-soft); - --el-bg-color-overlay: var(--c-bg); - --el-fill-color-blank: transparent; -} - -aside.sidebar { - top: 0; - z-index: 20; - - .sidebar-items { - padding-bottom: 0; - } - - .sidebar-items > li { - margin-bottom: 1rem; - } - - .sidebar-item { - color: var(--c-text-2); - } - - .sidebar-heading { - font-weight: 600; - font-size: 16px; - color: var(--c-text-1); - } -} - -div[class*=language-] { - background-color: transparent; -} - -div[class*=language-]::before { - display: none; -} - -.theme-default-content { - h1 { - line-height: 40px; - font-size: 32px; - } - - pre { - padding: 1rem 0; - } -} - -.k-icon { - transition: color 0.3s ease, background-color 0.3s ease; -} - -.theme-container.no-navbar .theme-default-content h1 { - margin-top: 3rem; -} - -a > img + span { - margin-left: 0.5rem; - > .external-link-icon { - display: none; - } -} - -code { - padding: 3px 6px; - transition: var(--color-transition); -} diff --git a/docs/.vuepress/theme.ts b/docs/.vuepress/theme.ts deleted file mode 100644 index ed052a5..0000000 --- a/docs/.vuepress/theme.ts +++ /dev/null @@ -1,16 +0,0 @@ -import type { Theme } from '@vuepress/core' -import { defaultTheme } from '@vuepress/theme-default' -import type { DefaultThemeOptions } from '@vuepress/theme-default' - -export default (options: DefaultThemeOptions): Theme => ({ - name: 'vuepress-theme-local', - extends: defaultTheme(options), - - layouts: { - Layout: require.resolve('./layout.vue'), - }, - - alias: { - '@theme/Sidebar.vue': require.resolve('./sidebar.vue'), - }, -}) diff --git a/docs/.vuepress/tsconfig.json b/docs/.vuepress/tsconfig.json deleted file mode 100644 index 0217e5e..0000000 --- a/docs/.vuepress/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "rootDir": ".", - "target": "esnext", - "module": "esnext", - "declaration": true, - "noEmit": true, - "composite": true, - "incremental": true, - "skipLibCheck": true, - "esModuleInterop": true, - "moduleResolution": "node", - "strictBindCallApply": true, - }, - "include": [ - "*", - ], -} \ No newline at end of file diff --git a/docs/atomic/bitset.md b/docs/atomic/bitset.md deleted file mode 100644 index 2a39312..0000000 --- a/docs/atomic/bitset.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -example: true -code: | - Schema.object({ - intents: Schema - .bitset({ FOO: 1, BAR: 2, QUX: 4 }).default(5) - .description('选择要启用的功能。'), - }).description('配置项') ---- - -# Bitset - -以 Bitset 的形式表达一个整数,通常每一位表达某种特征。 - -```ts -enum Intents { FOO = 1, BAR = 2, QUX = 4 } - -export default Schema.object({ - intents: Schema.bitset(Intents) - .default(Intents.FOO | Intents.QUX), -}) -``` diff --git a/docs/atomic/boolean.md b/docs/atomic/boolean.md deleted file mode 100644 index e821d7d..0000000 --- a/docs/atomic/boolean.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -example: true -code: | - Schema.object({ - enable: Schema.boolean().description('这是一个开关。'), - }).description('配置项') ---- - -# Boolean - -以开关的形式表达 boolean 类型的值。 - -```ts -export default Schema.object({ - enable: Schema.boolean(), -}) -``` diff --git a/docs/atomic/date.md b/docs/atomic/date.md deleted file mode 100644 index a55bbc0..0000000 --- a/docs/atomic/date.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -example: true -code: | - Schema.object({ - value: Schema.date().description('选择日期与时间 (对象)。'), - datetime: Schema.string().role('datetime').description('选择日期与时间 (字符串)。'), - date: Schema.string().role('date').description('选择日期 (字符串)。'), - time: Schema.string().role('time').description('选择时间 (字符串)。'), - }).description('配置项') ---- - -# Date - -由于 Date 不便于序列化,我们提供了两套描述 Date 的方式: - -- 使用 Date 类型:输入字符串,输出 Date 实例 -- 使用 String 类型与三种可选的 `role` 属性 - -其中,Date 类型与 `datetime` 的前端体验是完全一致的,唯一区别在于输出的格式不同。字符串额外多出 `date` 和 `time` 两种格式,用于表达纯日期和纯时间字符串。 - -```ts -export default Schema.object({ - value: Schema.date(), - datetime: Schema.string().role('datetime'), - date: Schema.string().role('date'), - time: Schema.string().role('time'), -}) -``` diff --git a/docs/atomic/number.md b/docs/atomic/number.md deleted file mode 100644 index 28d734e..0000000 --- a/docs/atomic/number.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -example: true -code: | - Schema.object({ - foo: Schema.number().description('一个普通的数值。'), - bar: Schema.number().role('slider').min(0).max(100).step(1).default(30).description('一个 0 到 100 之间的整数。'), - }).description('配置项') ---- - -# Number - -用于表达 number 类型的值,支持输入框和滑块。 - -```ts -export default Schema.object({ - foo: Schema.number(), - bar: Schema.number().role('slider') - .min(0).max(100).step(1).default(30), -}) -``` diff --git a/docs/atomic/string.md b/docs/atomic/string.md deleted file mode 100644 index 8919b27..0000000 --- a/docs/atomic/string.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -example: true -code: | - Schema.object({ - text: Schema.string().description('一段普通的文本。'), - secret: Schema.string().role('secret').default('114514').description('请输入密码。'), - link: Schema.string().role('link').default('https://github.com').description('点击访问链接。'), - area: Schema.string().role('textarea').description('在下方输入多行文本。'), - }).description('配置项') ---- - -# String - -用于表达 string 类型的值,支持多种特殊模式。 - -- secret:默认情况下不显示输入框中的内容,可点击按钮切换 -- link:点击可访问输入框中的链接 (同时输入框也会稍长一些) -- textarea:输入框显示在下方,为自适应高度的多行文本框 - -```ts -export default Schema.object({ - text: Schema.string(), - secret: Schema.string().role('secret') - .default('114514'), - link: Schema.string().role('link') - .default('https://github.com'), - area: Schema.string().role('textarea'), -}) -``` diff --git a/docs/composite/array.md b/docs/composite/array.md deleted file mode 100644 index 9a34320..0000000 --- a/docs/composite/array.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -example: true -code: | - Schema.object({ - values: Schema.array(Number).description('这是一个数组,点击右侧的按钮添加元素。'), - }).description('配置项') ---- - -# Array - -Array 类型描述了一个数组,其中的元素满足给定的类型。例子里的 `Number` 是 `Schema.number()` 的简写。 - -```ts -export default Schema.object({ - values: Schema.array(Number), -}) -``` diff --git a/docs/composite/dict.md b/docs/composite/dict.md deleted file mode 100644 index dd578f4..0000000 --- a/docs/composite/dict.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -example: true -code: | - Schema.object({ - values: Schema.dict(Boolean).description('这是一个字典,点击右侧的按钮添加属性。'), - }).description('配置项') ---- - -# Dict - -Dict 类型描述了一个对象,其中的键是任意字符串,而值是给定的类型。例子里的 `Boolean` 是 `Schema.boolean()` 的简写。 - -```ts -export default Schema.object({ - values: Schema.dict(Boolean), -}) -``` diff --git a/docs/composite/intersect.md b/docs/composite/intersect.md deleted file mode 100644 index cead279..0000000 --- a/docs/composite/intersect.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -example: true -code: | - Schema.intersect([ - Schema.object({ - foo: Schema.number().description('这是一个属性。'), - bar: Schema.string().description('这是另一个属性。'), - }).description('分组 1'), - Schema.object({ - baz: Schema.string().description('这是又一个属性。'), - qux: Schema.boolean().description('这是最后一个属性。'), - }).description('分组 2'), - ]) ---- - -# Intersect - -Intersect 类型可用于合并多个类型。一种最常见的用法是将配置项分为多组显示。 - -```ts -export default Schema.intersect([ - Schema.object({ - foo: Schema.number(), - bar: Schema.string(), - }).description('分组 1'), - Schema.object({ - baz: Schema.string(), - qux: Schema.boolean(), - }).description('分组 2'), -]) -``` diff --git a/docs/composite/object.md b/docs/composite/object.md deleted file mode 100644 index 7e8a06b..0000000 --- a/docs/composite/object.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -example: true -code: | - Schema.object({ - foo: Schema.string().required().description('这是一个必需属性。'), - bar: Schema.number().description('这是一个可选属性。'), - baz: Schema.object({ - qux: Schema.boolean().description('这是一个嵌套属性。'), - }), - }).description('配置项') ---- - -# Object - -Object 类型描述了一个具有给定属性的对象。默认情况下所有属性都是可选的,可以通过 `.required()` 来声明一个必需属性。 - -```ts -export default Schema.object({ - foo: Schema.string().required(), - bar: Schema.number(), - baz: Schema.object({ - qux: Schema.boolean(), - }), -}).description('配置项') -``` diff --git a/docs/composite/transform.md b/docs/composite/transform.md deleted file mode 100644 index 65bfa8e..0000000 --- a/docs/composite/transform.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -example: true -code: | - Schema.object({ - value: Schema.union([ - Schema.array(String), - Schema.transform(String, value => [value]), - ]).default([]).description('点击右侧的按钮添加元素。'), - }).description('配置项') ---- - -# Transform - -Transform 用于定义一个转换类型,通常与 Union 一同使用。当输入满足一参数类型时,将调用二参数转换输入作为输出。此次转换将直接修改输入的对象,以确保类型满足输出类型。在网页表单中,将只会显示输出类型。 - -```ts -export default Schema.object({ - value: Schema.union([ - Schema.array(String), - Schema.transform(String, value => [value]), - ]).default([]), -}) -``` diff --git a/docs/composite/tuple.md b/docs/composite/tuple.md deleted file mode 100644 index 43ff9f5..0000000 --- a/docs/composite/tuple.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -example: true -code: | - Schema.object({ - point: Schema.tuple([Number, Number]).description('请输入点的坐标。'), - }).description('配置项') ---- - -# Tuple - -Tuple 类型描述了一个数组,它的长度是固定的,你需要分别给出其中每个元素的类型。它们会被显示在同一行中。 - -注意:尽管在验证时 tuple 支持传入任何子类型,但用作表单时,我们只接受内部元素是原始类型的情况。如果你要描述类型比较复杂,推荐使用 object 或 array 替代。 - -```ts -export default Schema.object({ - point: Schema.tuple([Number, Number]), -}) -``` diff --git a/docs/composite/union-arbitrary.md b/docs/composite/union-arbitrary.md deleted file mode 100644 index 132eeee..0000000 --- a/docs/composite/union-arbitrary.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -example: true -code: | - Schema.object({ - value: Schema.union([ - Schema.const().description('unset'), - Schema.number().description('number'), - Schema.string().description('string'), - Schema.const(true).description('true'), - Schema.const(false).description('false'), - Schema.object({ - foo: Schema.string(), - bar: Schema.number(), - }).description('object'), - ]).description('从六种可能情况中选择一个。'), - }).description('配置项') ---- - -# Union (Arbitrary) - -Union 同样支持多种不同类型的联合。你需要给每个子类型提供一个 description,它们会作为表单中呈现的选项。 - -```ts -export default Schema.object({ - value: Schema.union([ - Schema.const().description('unset'), - Schema.number().description('number'), - Schema.string().description('string'), - Schema.const(true).description('true'), - Schema.const(false).description('false'), - Schema.object({ - foo: Schema.string(), - bar: Schema.number(), - }).description('object'), - ]), -}) -``` diff --git a/docs/composite/union-select.md b/docs/composite/union-select.md deleted file mode 100644 index ac1f176..0000000 --- a/docs/composite/union-select.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -example: true -code: | - Schema.object({ - value1: Schema.union(['foo', 'bar', 'qux']).description('从三个值中选择一个。'), - value2: Schema.union([ - Schema.const('foo').description('选项 1'), - Schema.const('bar').description('选项 2'), - Schema.const('baz').description('选项 3'), - ]).role('radio').description('从三个值中选择一个。'), - }).description('配置项') ---- - -# Union (Select) - -Union 描述了多个子类型的联合。它的最基础形式是从多个固定值中选择一个。这里的每一个字符串是 `Schema.const()` 的简写形式。如果每个可选值有较长的描述文本,你可以进一步将 `role` 设置为 `radio`,这样一来所有的选项将显示在下方而不是右侧。 - -```ts -export default Schema.object({ - value1: Schema.union(['foo', 'bar', 'qux']), - value2: Schema.union([ - Schema.const('foo').description('选项 1'), - Schema.const('bar').description('选项 2'), - Schema.const('baz').description('选项 3'), - ]).role('radio'), -}) -``` diff --git a/docs/composite/union-tagged-1.md b/docs/composite/union-tagged-1.md deleted file mode 100644 index f9f7ab7..0000000 --- a/docs/composite/union-tagged-1.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -example: true -code: | - Schema.intersect([ - Schema.object({ - shared: Schema.string().description('公用的配置项。'), - type: Schema.union(['foo', 'bar']).required().description('选择一个类型。'), - }).description('基础配置'), - Schema.union([ - Schema.object({ - type: Schema.const('foo').required(), - value: Schema.number().default(114514).description('请输入一个数值。'), - }).description('特殊配置 1'), - Schema.object({ - type: Schema.const('bar').required(), - text: Schema.string().description('请输入一个字符串。'), - }).description('特殊配置 2'), - ]), - ]) ---- - -# Union (Tagged 1) - -一种比较复杂的场景是以对象的某个属性值确定对象的其他属性的类型。善用 Intersect 和 Union,我们就可以轻松实现表单项的联动效果!试着切换 `type` 的取值,并观察下方表单项的变化吧。 - -```ts -export default Schema.intersect([ - Schema.object({ - shared: Schema.string(), - type: Schema.union(['foo', 'bar']).required(), - }).description('基础配置'), - Schema.union([ - Schema.object({ - type: Schema.const('foo').required(), - value: Schema.number().default(114514), - }).description('特殊配置 1'), - Schema.object({ - type: Schema.const('bar').required(), - text: Schema.string(), - }).description('特殊配置 2'), - ]), -]) -``` diff --git a/docs/composite/union-tagged-2.md b/docs/composite/union-tagged-2.md deleted file mode 100644 index 8a8d540..0000000 --- a/docs/composite/union-tagged-2.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -example: true -code: | - Schema.intersect([ - Schema.object({ - enabled: Schema.boolean().default(false).description('是否开启功能'), - }).description('基础配置'), - Schema.union([ - Schema.object({ - enabled: Schema.const(true).required(), - foo: Schema.number().description('请输入一个数值。'), - bar: Schema.string().description('请输入一个字符串。'), - }), - Schema.object({}), - ]), - ]) ---- - -# Union (Tagged 2) - -一种比较复杂的场景是以对象的某个属性值确定对象的其他属性的类型。善用 Intersect 和 Union,我们就可以轻松实现表单项的联动效果!试着切换 `type` 的取值,并观察下方表单项的变化吧。 - -```ts -export default Schema.intersect([ - Schema.object({ - enabled: Schema.boolean().default(false), - }).description('基础配置'), - Schema.union([ - Schema.object({ - enabled: Schema.const(true).required(), - foo: Schema.number().description('请输入一个数值。'), - bar: Schema.string().description('请输入一个字符串。'), - }), - Schema.object({}), - ]) -]) -``` diff --git a/docs/index.md b/docs/index.md deleted file mode 120000 index 5dc8517..0000000 --- a/docs/index.md +++ /dev/null @@ -1 +0,0 @@ -../packages/core/README.md \ No newline at end of file diff --git a/docs/meta/default.md b/docs/meta/default.md deleted file mode 100644 index 2140650..0000000 --- a/docs/meta/default.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -example: true -code: | - Schema.object({ - foo: Schema.string().default('lol'), - bar: Schema.number().default(2333), - }).description('配置项') ---- - -# .default() - -`.default()` 用于设置某个类型的默认值。默认值会作为初始状态呈现在表单中,但它并不意味着修改你传入的配置。正相反,如果你将某个配置项修改为了默认值,则该配置项实际上会被清除,以确保配置文件的简洁性。 - -```ts -export default Schema.object({ - foo: Schema.string().default('lol'), - bar: Schema.number().default(2333), -}) -``` diff --git a/docs/meta/description.md b/docs/meta/description.md deleted file mode 100644 index 0fdcf5b..0000000 --- a/docs/meta/description.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -example: true -code: | - Schema.object({ - foo: Schema.boolean().description('这是*斜体*属性。'), - bar: Schema.string().description('这是**粗体**属性。'), - }).description('配置项') ---- - -# .description() - -`.description()` 用于设置某个类型的描述文本。当添加在属性上时会显示在名称下方,当添加在对象上时则会表现为小标题。我们还支持了基本的行内 Markdown 语法。 - -```ts -export default Schema.object({ - foo: Schema.boolean().description('这是*斜体*属性。'), - bar: Schema.string().description('这是**粗体**属性。'), -}).description('配置项') -``` diff --git a/docs/meta/hidden.md b/docs/meta/hidden.md deleted file mode 100644 index 297e691..0000000 --- a/docs/meta/hidden.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -example: true -code: | - Schema.object({ - foo: Schema.string().description('这是一个可见属性。'), - bar: Schema.number().hidden(), - }).description('配置项') ---- - -# .hidden() - -`.hidden()` 用于隐藏某个类型。具有隐藏类型的配置项不会呈现在表单中,但是仍然会参与类型检查。许多应用会同时提供 API 和网页表单,而开发者可能不希望将全部配置项都提供给表单的填写者 (例如复杂的底层配置或者实验性设置)。在这种情况下,隐藏部分配置项将会是一个好的选择。 - -```ts -export default Schema.object({ - foo: Schema.string(), - bar: Schema.number().hidden(), -}) -``` diff --git a/docs/meta/required.md b/docs/meta/required.md deleted file mode 100644 index 99f73e1..0000000 --- a/docs/meta/required.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -example: true -code: | - Schema.object({ - foo: Schema.string().required().description('这是一个必需属性。'), - }).description('配置项') ---- - -# .required() - -`.required()` 限制一个类型是 nullable 的能力 (我们不区分 `null` 和 `undefined`)。默认情况下,所有配置项都是可选的;必需的配置项的左侧会出现红色的提示线。 - -```ts -export default Schema.object({ - foo: Schema.string().required(), -}) -``` diff --git a/docs/meta/role.md b/docs/meta/role.md deleted file mode 100644 index b83abcd..0000000 --- a/docs/meta/role.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -example: true -code: | - Schema.intersect([ - Schema.object({ - number: Schema.percent().role('').default(0.5).description('点击按钮修改数值。'), - string: Schema.string().default('password').description('可见的输入框。'), - choice: Schema.union(['foo', 'bar', 'qux']).default('foo').description('从选择器中取值。'), - }).description('配置项 1'), - Schema.object({ - number: Schema.percent().role('slider').default(0.5).description('拖动滑块修改数值。'), - string: Schema.string().role('secret').default('password').description('隐藏的密码框。'), - choice: Schema.union(['foo', 'bar', 'qux']).default('foo').role('radio').description('从单选框中取值。'), - }).description('配置项 2'), - ]) ---- - -# .role() - -`.role()` 描述了一个配置项的外观,而不会影响该类型的实际行为。不同类型的可选外观各有不同,我们将在每种类型的示例中分别介绍。 - -```ts -export default Schema.object({ - number: Schema.percent().role(''), - string: Schema.string().role(''), - choice: Schema - .union(['foo', 'bar', 'qux']) - .role(''), -}) - -export default Schema.object({ - number: Schema.percent().role('slider'), - string: Schema.string().role('secret'), - choice: Schema - .union(['foo', 'bar', 'qux']) - .role('radio'), -}) -```