@bitrix24/b24ui-nuxt 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/.nuxt/b24ui/advice.ts +52 -0
- package/.nuxt/b24ui/alert.ts +118 -0
- package/.nuxt/b24ui/avatar-group.ts +52 -0
- package/.nuxt/b24ui/avatar.ts +63 -0
- package/.nuxt/b24ui/badge.ts +256 -0
- package/.nuxt/b24ui/button-group.ts +27 -0
- package/.nuxt/b24ui/button.ts +342 -0
- package/.nuxt/b24ui/checkbox.ts +128 -0
- package/.nuxt/b24ui/chip.ts +205 -0
- package/.nuxt/b24ui/container.ts +3 -0
- package/.nuxt/b24ui/content/description-list.ts +62 -0
- package/.nuxt/b24ui/countdown.ts +94 -0
- package/.nuxt/b24ui/form-field.ts +57 -0
- package/.nuxt/b24ui/form.ts +3 -0
- package/.nuxt/b24ui/index.ts +28 -0
- package/.nuxt/b24ui/input.ts +472 -0
- package/.nuxt/b24ui/kbd.ts +31 -0
- package/.nuxt/b24ui/link.ts +20 -0
- package/.nuxt/b24ui/progress.ts +303 -0
- package/.nuxt/b24ui/radio-group.ts +135 -0
- package/.nuxt/b24ui/range.ts +172 -0
- package/.nuxt/b24ui/select.ts +550 -0
- package/.nuxt/b24ui/separator.ts +176 -0
- package/.nuxt/b24ui/skeleton.ts +3 -0
- package/.nuxt/b24ui/switch.ts +134 -0
- package/.nuxt/b24ui/tabs.ts +341 -0
- package/.nuxt/b24ui/textarea.ts +332 -0
- package/.nuxt/b24ui/toast.ts +89 -0
- package/.nuxt/b24ui/toaster.ts +91 -0
- package/.nuxt/b24ui/tooltip.ts +16 -0
- package/LICENSE +21 -0
- package/README.md +101 -0
- package/cli/commands/make/component.mjs +95 -0
- package/cli/commands/make/index.mjs +14 -0
- package/cli/commands/make/locale.mjs +64 -0
- package/cli/index.mjs +15 -0
- package/cli/package.json +13 -0
- package/cli/templates.mjs +240 -0
- package/cli/utils.mjs +31 -0
- package/dist/meta.cjs +23610 -0
- package/dist/meta.d.cts +23608 -0
- package/dist/meta.d.mts +23608 -0
- package/dist/meta.d.ts +23608 -0
- package/dist/meta.mjs +23608 -0
- package/dist/module.cjs +54 -0
- package/dist/module.d.cts +14 -0
- package/dist/module.d.mts +14 -0
- package/dist/module.d.ts +14 -0
- package/dist/module.json +13 -0
- package/dist/module.mjs +51 -0
- package/dist/runtime/components/Advice.vue +115 -0
- package/dist/runtime/components/Alert.vue +136 -0
- package/dist/runtime/components/App.vue +52 -0
- package/dist/runtime/components/Avatar.vue +118 -0
- package/dist/runtime/components/AvatarGroup.vue +99 -0
- package/dist/runtime/components/Badge.vue +114 -0
- package/dist/runtime/components/Button.vue +177 -0
- package/dist/runtime/components/ButtonGroup.vue +58 -0
- package/dist/runtime/components/Checkbox.vue +110 -0
- package/dist/runtime/components/Chip.vue +81 -0
- package/dist/runtime/components/Container.vue +36 -0
- package/dist/runtime/components/Countdown.vue +498 -0
- package/dist/runtime/components/Form.vue +271 -0
- package/dist/runtime/components/FormField.vue +128 -0
- package/dist/runtime/components/Input.vue +224 -0
- package/dist/runtime/components/Kbd.vue +50 -0
- package/dist/runtime/components/Link.vue +219 -0
- package/dist/runtime/components/LinkBase.vue +63 -0
- package/dist/runtime/components/Progress.vue +182 -0
- package/dist/runtime/components/RadioGroup.vue +178 -0
- package/dist/runtime/components/Range.vue +114 -0
- package/dist/runtime/components/Select.vue +328 -0
- package/dist/runtime/components/Separator.vue +82 -0
- package/dist/runtime/components/Skeleton.vue +31 -0
- package/dist/runtime/components/Switch.vue +133 -0
- package/dist/runtime/components/Tabs.vue +127 -0
- package/dist/runtime/components/Textarea.vue +216 -0
- package/dist/runtime/components/Toast.vue +168 -0
- package/dist/runtime/components/Toaster.vue +143 -0
- package/dist/runtime/components/Tooltip.vue +94 -0
- package/dist/runtime/components/content/DescriptionList.vue +220 -0
- package/dist/runtime/composables/defineLocale.d.ts +9 -0
- package/dist/runtime/composables/defineLocale.js +4 -0
- package/dist/runtime/composables/defineShortcuts.d.ts +15 -0
- package/dist/runtime/composables/defineShortcuts.js +135 -0
- package/dist/runtime/composables/useAvatarGroup.d.ts +10 -0
- package/dist/runtime/composables/useAvatarGroup.js +10 -0
- package/dist/runtime/composables/useButtonGroup.d.ts +17 -0
- package/dist/runtime/composables/useButtonGroup.js +10 -0
- package/dist/runtime/composables/useComponentIcons.d.ts +20 -0
- package/dist/runtime/composables/useComponentIcons.js +25 -0
- package/dist/runtime/composables/useFormField.d.ts +42 -0
- package/dist/runtime/composables/useFormField.js +65 -0
- package/dist/runtime/composables/useKbd.d.ts +35 -0
- package/dist/runtime/composables/useKbd.js +52 -0
- package/dist/runtime/composables/useLocale.d.ts +4 -0
- package/dist/runtime/composables/useLocale.js +10 -0
- package/dist/runtime/composables/useToast.d.ts +12 -0
- package/dist/runtime/composables/useToast.js +62 -0
- package/dist/runtime/dictionary/icons.d.ts +20 -0
- package/dist/runtime/dictionary/icons.js +35 -0
- package/dist/runtime/index.css +1 -0
- package/dist/runtime/keyframes.css +1 -0
- package/dist/runtime/locale/en.d.ts +2 -0
- package/dist/runtime/locale/en.js +48 -0
- package/dist/runtime/locale/es.d.ts +2 -0
- package/dist/runtime/locale/es.js +48 -0
- package/dist/runtime/locale/index.d.ts +3 -0
- package/dist/runtime/locale/index.js +3 -0
- package/dist/runtime/locale/ru.d.ts +2 -0
- package/dist/runtime/locale/ru.js +48 -0
- package/dist/runtime/plugins/colors.d.ts +2 -0
- package/dist/runtime/plugins/colors.js +40 -0
- package/dist/runtime/types/app.config.d.ts +6 -0
- package/dist/runtime/types/form.d.ts +84 -0
- package/dist/runtime/types/form.js +12 -0
- package/dist/runtime/types/icons.d.ts +3 -0
- package/dist/runtime/types/icons.js +0 -0
- package/dist/runtime/types/index.d.ts +33 -0
- package/dist/runtime/types/index.js +33 -0
- package/dist/runtime/types/locale.d.ts +50 -0
- package/dist/runtime/types/locale.js +0 -0
- package/dist/runtime/types/utils.d.ts +22 -0
- package/dist/runtime/types/utils.js +0 -0
- package/dist/runtime/utils/form.d.ts +17 -0
- package/dist/runtime/utils/form.js +153 -0
- package/dist/runtime/utils/fuse.d.ts +4 -0
- package/dist/runtime/utils/fuse.js +63 -0
- package/dist/runtime/utils/index.d.ts +6 -0
- package/dist/runtime/utils/index.js +63 -0
- package/dist/runtime/utils/link.d.ts +29 -0
- package/dist/runtime/utils/link.js +4 -0
- package/dist/runtime/utils/locale.d.ts +15 -0
- package/dist/runtime/utils/locale.js +25 -0
- package/dist/runtime/utils/tv.d.ts +1 -0
- package/dist/runtime/utils/tv.js +4 -0
- package/dist/runtime/vue/components/Link.vue +203 -0
- package/dist/runtime/vue/plugins/color-mode.d.ts +4 -0
- package/dist/runtime/vue/plugins/color-mode.js +6 -0
- package/dist/runtime/vue/plugins/head.d.ts +4 -0
- package/dist/runtime/vue/plugins/head.js +6 -0
- package/dist/runtime/vue/stubs.d.ts +15 -0
- package/dist/runtime/vue/stubs.js +27 -0
- package/dist/shared/b24ui-nuxt.CNGvMe2S.mjs +4074 -0
- package/dist/shared/b24ui-nuxt.D22QQtm8.cjs +4079 -0
- package/dist/types.d.mts +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/unplugin.cjs +213 -0
- package/dist/unplugin.d.cts +22 -0
- package/dist/unplugin.d.mts +22 -0
- package/dist/unplugin.d.ts +22 -0
- package/dist/unplugin.mjs +202 -0
- package/dist/vite.cjs +21 -0
- package/dist/vite.d.cts +12 -0
- package/dist/vite.d.mts +12 -0
- package/dist/vite.d.ts +12 -0
- package/dist/vite.mjs +19 -0
- package/package.json +166 -0
- package/vue-plugin.d.ts +5 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { existsSync, promises as fsp } from 'node:fs'
|
|
2
|
+
import { resolve } from 'pathe'
|
|
3
|
+
import { defineCommand } from 'citty'
|
|
4
|
+
import { consola } from 'consola'
|
|
5
|
+
import { splitByCase, upperFirst, camelCase, kebabCase } from 'scule'
|
|
6
|
+
import { appendFile, sortFile } from '../../utils.mjs'
|
|
7
|
+
import templates from '../../templates.mjs'
|
|
8
|
+
|
|
9
|
+
export default defineCommand({
|
|
10
|
+
meta: {
|
|
11
|
+
name: 'component',
|
|
12
|
+
description: 'Make a new component.'
|
|
13
|
+
},
|
|
14
|
+
args: {
|
|
15
|
+
name: {
|
|
16
|
+
type: 'positional',
|
|
17
|
+
required: true,
|
|
18
|
+
description: 'Name of the component.'
|
|
19
|
+
},
|
|
20
|
+
primitive: {
|
|
21
|
+
type: 'boolean',
|
|
22
|
+
description: 'Create a primitive component.'
|
|
23
|
+
},
|
|
24
|
+
pro: {
|
|
25
|
+
type: 'boolean',
|
|
26
|
+
description: 'Create a pro component.'
|
|
27
|
+
},
|
|
28
|
+
prose: {
|
|
29
|
+
type: 'boolean',
|
|
30
|
+
description: 'Create a prose component (with --pro).'
|
|
31
|
+
},
|
|
32
|
+
content: {
|
|
33
|
+
type: 'boolean',
|
|
34
|
+
description: 'Create a content component (with --pro).'
|
|
35
|
+
},
|
|
36
|
+
template: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
description: 'Only generate template.'
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
async setup({ args }) {
|
|
42
|
+
const name = args.name
|
|
43
|
+
if (!name) {
|
|
44
|
+
consola.error('`name` argument is missing!')
|
|
45
|
+
process.exit(1)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (args.prose && !args.pro) {
|
|
49
|
+
consola.error('`--prose` flag can only be used with `--pro` flag!')
|
|
50
|
+
process.exit(1)
|
|
51
|
+
}
|
|
52
|
+
if (args.content && !args.pro) {
|
|
53
|
+
consola.error('`--content` flag can only be used with `--pro` flag!')
|
|
54
|
+
process.exit(1)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const path = resolve('.')
|
|
58
|
+
|
|
59
|
+
for (const template of Object.keys(templates)) {
|
|
60
|
+
if (args.template && template !== args.template) {
|
|
61
|
+
continue
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const { filename, contents } = templates[template](args)
|
|
65
|
+
if (!contents) {
|
|
66
|
+
continue
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const filePath = resolve(path, filename)
|
|
70
|
+
|
|
71
|
+
if (existsSync(filePath)) {
|
|
72
|
+
consola.error(`🚨 ${filePath} already exists!`)
|
|
73
|
+
continue
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
await fsp.writeFile(filePath, contents.trim() + '\n')
|
|
77
|
+
|
|
78
|
+
consola.success(`Generated ${filePath}!`)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (args.template) {
|
|
82
|
+
return
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const themePath = resolve(path, `src/theme/${args.prose ? 'prose/' : ''}${args.content ? 'content/' : ''}index.ts`)
|
|
86
|
+
await appendFile(themePath, `export { default as ${camelCase(name)} } from './${kebabCase(name)}'`)
|
|
87
|
+
await sortFile(themePath)
|
|
88
|
+
|
|
89
|
+
if (!args.prose) {
|
|
90
|
+
const typesPath = resolve(path, 'src/runtime/types/index.ts')
|
|
91
|
+
await appendFile(typesPath, `export * from '../components/${args.content ? 'content/' : ''}${splitByCase(name).map(p => upperFirst(p)).join('')}.vue'`)
|
|
92
|
+
await sortFile(typesPath)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
})
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineCommand } from 'citty'
|
|
2
|
+
import component from './component.mjs'
|
|
3
|
+
import locale from './locale.mjs'
|
|
4
|
+
|
|
5
|
+
export default defineCommand({
|
|
6
|
+
meta: {
|
|
7
|
+
name: 'make',
|
|
8
|
+
description: 'Commands to create new Bitrix24 UI entities.'
|
|
9
|
+
},
|
|
10
|
+
subCommands: {
|
|
11
|
+
component,
|
|
12
|
+
locale
|
|
13
|
+
}
|
|
14
|
+
})
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { existsSync, promises as fsp } from 'node:fs'
|
|
2
|
+
import { resolve } from 'pathe'
|
|
3
|
+
import { consola } from 'consola'
|
|
4
|
+
import { appendFile, sortFile, normalizeLocale } from '../../utils.mjs'
|
|
5
|
+
import { defineCommand } from 'citty'
|
|
6
|
+
|
|
7
|
+
export default defineCommand({
|
|
8
|
+
meta: {
|
|
9
|
+
name: 'locale',
|
|
10
|
+
description: 'Make a new locale.'
|
|
11
|
+
},
|
|
12
|
+
args: {
|
|
13
|
+
code: {
|
|
14
|
+
description: 'Locale code to create. For example: en.',
|
|
15
|
+
required: true
|
|
16
|
+
},
|
|
17
|
+
name: {
|
|
18
|
+
description: 'Locale name to create. For example: English.',
|
|
19
|
+
required: true
|
|
20
|
+
},
|
|
21
|
+
dir: {
|
|
22
|
+
description: 'Locale direction. For example: rtl.',
|
|
23
|
+
default: 'ltr'
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
async setup({ args }) {
|
|
27
|
+
const path = resolve('.')
|
|
28
|
+
const localePath = resolve(path, `src/runtime/locale`)
|
|
29
|
+
|
|
30
|
+
const originLocaleFilePath = resolve(localePath, 'en.ts')
|
|
31
|
+
const newLocaleFilePath = resolve(localePath, `${args.code}.ts`)
|
|
32
|
+
|
|
33
|
+
// Validate locale code
|
|
34
|
+
if (existsSync(newLocaleFilePath)) {
|
|
35
|
+
consola.error(`🚨 ${args.code} already exists!`)
|
|
36
|
+
process.exit(1)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!['ltr', 'rtl'].includes(args.dir)) {
|
|
40
|
+
consola.error(`🚨 Direction ${args.dir} not supported!`)
|
|
41
|
+
process.exit(1)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!args.code.match(/^[a-z]{2}(?:_[a-z]{2,4})?$/)) {
|
|
45
|
+
consola.error(`🚨 ${args.code} is not a valid locale code!\nExample: en or en_us`)
|
|
46
|
+
process.exit(1)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Create new locale export
|
|
50
|
+
const localeExportFile = resolve(localePath, `index.ts`)
|
|
51
|
+
await appendFile(localeExportFile, `export { default as ${args.code} } from './${args.code}'`)
|
|
52
|
+
await sortFile(localeExportFile)
|
|
53
|
+
|
|
54
|
+
// Create new locale file
|
|
55
|
+
await fsp.copyFile(originLocaleFilePath, newLocaleFilePath)
|
|
56
|
+
const localeFile = await fsp.readFile(newLocaleFilePath, 'utf-8')
|
|
57
|
+
const rewrittenLocaleFile = localeFile
|
|
58
|
+
.replace(/name: '(.*)',/, `name: '${args.name}',`)
|
|
59
|
+
.replace(/code: '(.*)',/, `code: '${normalizeLocale(args.code)}',${(args.dir && args.dir !== 'ltr') ? `\n dir: '${args.dir}',` : ''}`)
|
|
60
|
+
await fsp.writeFile(newLocaleFilePath, rewrittenLocaleFile)
|
|
61
|
+
|
|
62
|
+
consola.success(`🪄 Generated ${newLocaleFilePath}`)
|
|
63
|
+
}
|
|
64
|
+
})
|
package/cli/index.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { defineCommand, runMain } from 'citty'
|
|
3
|
+
import make from './commands/make/index.mjs'
|
|
4
|
+
|
|
5
|
+
const main = defineCommand({
|
|
6
|
+
meta: {
|
|
7
|
+
name: 'bitrix24-ui',
|
|
8
|
+
description: 'Bitrix24 UI CLI'
|
|
9
|
+
},
|
|
10
|
+
subCommands: {
|
|
11
|
+
make
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
runMain(main)
|
package/cli/package.json
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { splitByCase, upperFirst, camelCase, kebabCase } from 'scule'
|
|
2
|
+
|
|
3
|
+
function replaceBrackets(value) {
|
|
4
|
+
return value.replace(/\[\[/g, '<').replace(/\]\]/g, '>')
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const playground = ({ name, pro }) => {
|
|
8
|
+
const upperName = splitByCase(name).map(p => upperFirst(p)).join('')
|
|
9
|
+
const kebabName = kebabCase(name)
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
filename: `playground/app/pages/components/${kebabName}.vue`,
|
|
13
|
+
contents: pro
|
|
14
|
+
? undefined
|
|
15
|
+
: replaceBrackets(`
|
|
16
|
+
[[template]]
|
|
17
|
+
[[div]]
|
|
18
|
+
[[B24${upperName} /]]
|
|
19
|
+
[[/div]]
|
|
20
|
+
[[/template]]
|
|
21
|
+
`)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const component = ({ name, primitive, pro, prose, content }) => {
|
|
26
|
+
const upperName = splitByCase(name).map(p => upperFirst(p)).join('')
|
|
27
|
+
const camelName = camelCase(name)
|
|
28
|
+
const kebabName = kebabCase(name)
|
|
29
|
+
const key = 'b24ui'
|
|
30
|
+
const path = 'b24ui'
|
|
31
|
+
|
|
32
|
+
if (pro) {
|
|
33
|
+
// pro
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
filename: `src/runtime/components/${prose ? 'prose/' : ''}${content ? 'content/' : ''}${upperName}.vue`,
|
|
38
|
+
contents: primitive
|
|
39
|
+
? replaceBrackets(`
|
|
40
|
+
[[script lang="ts"]]
|
|
41
|
+
import type { AppConfig } from '@nuxt/schema'
|
|
42
|
+
import _appConfig from '#build/app.config'
|
|
43
|
+
import theme from '#build/${path}/${prose ? 'prose/' : ''}${content ? 'content/' : ''}${kebabName}'
|
|
44
|
+
import { tv } from '../utils/tv'
|
|
45
|
+
|
|
46
|
+
const appConfig${camelName} = _appConfig as AppConfig & { ${key}: { ${prose ? 'prose: { ' : ''}${camelName}: Partial<typeof theme> } }${prose ? ' }' : ''}
|
|
47
|
+
|
|
48
|
+
const ${camelName} = tv({ extend: tv(theme), ...(appConfig${camelName}.${key}?.${prose ? 'prose?.' : ''}${camelName} || {}) })
|
|
49
|
+
|
|
50
|
+
export interface ${upperName}Props {
|
|
51
|
+
/**
|
|
52
|
+
* The element or component this component should render as.
|
|
53
|
+
* @defaultValue 'div'
|
|
54
|
+
*/
|
|
55
|
+
as?: any
|
|
56
|
+
class?: any
|
|
57
|
+
b24ui?: Partial<typeof ${camelName}.slots>
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface ${upperName}Slots {
|
|
61
|
+
default(props?: {}): any
|
|
62
|
+
}
|
|
63
|
+
[[/script]]
|
|
64
|
+
|
|
65
|
+
[[script setup lang="ts"]]
|
|
66
|
+
import { Primitive } from 'reka-ui'
|
|
67
|
+
|
|
68
|
+
const props = defineProps<${upperName}Props>()
|
|
69
|
+
defineSlots<${upperName}Slots>()
|
|
70
|
+
|
|
71
|
+
const b24ui = ${camelName}()
|
|
72
|
+
[[/script]]
|
|
73
|
+
|
|
74
|
+
[[template]]
|
|
75
|
+
[[Primitive :as="as" :class="b24ui.root({ class: [props.class, props.b24ui?.root] })"]]
|
|
76
|
+
[[slot /]]
|
|
77
|
+
[[/Primitive]]
|
|
78
|
+
[[/template]]
|
|
79
|
+
`)
|
|
80
|
+
: replaceBrackets(`
|
|
81
|
+
[[script lang="ts"]]
|
|
82
|
+
import type { VariantProps } from 'tailwind-variants'
|
|
83
|
+
import type { ${upperName}RootProps, ${upperName}RootEmits } from 'reka-ui'
|
|
84
|
+
import type { AppConfig } from '@nuxt/schema'
|
|
85
|
+
import _appConfig from '#build/app.config'
|
|
86
|
+
import theme from '#build/${path}/${prose ? 'prose/' : ''}${content ? 'content/' : ''}${kebabName}'
|
|
87
|
+
import { tv } from '../utils/tv'
|
|
88
|
+
|
|
89
|
+
const appConfig${camelName} = _appConfig as AppConfig & { ${key}: { ${prose ? 'prose: { ' : ''}${camelName}: Partial[[typeof theme]] } }${prose ? ' }' : ''}
|
|
90
|
+
|
|
91
|
+
const ${camelName} = tv({ extend: tv(theme), ...(appConfig${camelName}.${key}?.${prose ? 'prose?.' : ''}${camelName} || {}) })
|
|
92
|
+
|
|
93
|
+
type ${upperName}Variants = VariantProps[[typeof ${camelName}]]
|
|
94
|
+
|
|
95
|
+
export interface ${upperName}Props extends Pick[[${upperName}RootProps]] {
|
|
96
|
+
class?: any
|
|
97
|
+
b24ui?: Partial[[typeof ${camelName}.slots]]
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface ${upperName}Emits extends ${upperName}RootEmits {}
|
|
101
|
+
|
|
102
|
+
export interface ${upperName}Slots {}
|
|
103
|
+
[[/script]]
|
|
104
|
+
|
|
105
|
+
[[script setup lang="ts"]]
|
|
106
|
+
import { ${upperName}Root, useForwardPropsEmits } from 'reka-ui'
|
|
107
|
+
import { reactivePick } from '@vueuse/core'
|
|
108
|
+
|
|
109
|
+
const props = defineProps<${upperName}Props>()
|
|
110
|
+
const emits = defineEmits<${upperName}Emits>()
|
|
111
|
+
const slots = defineSlots<${upperName}Slots>()
|
|
112
|
+
|
|
113
|
+
const rootProps = useForwardPropsEmits(reactivePick(props), emits)
|
|
114
|
+
|
|
115
|
+
const b24ui = ${camelName}()
|
|
116
|
+
[[/script]]
|
|
117
|
+
|
|
118
|
+
[[template]]
|
|
119
|
+
[[${upperName}Root v-bind="rootProps" :class="b24ui.root({ class: [props.class, props.b24ui?.root] })" /]]
|
|
120
|
+
[[/template]]
|
|
121
|
+
`)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const theme = ({ name, prose, content }) => {
|
|
126
|
+
const kebabName = kebabCase(name)
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
filename: `src/theme/${prose ? 'prose/' : ''}${content ? 'content/' : ''}${kebabName}.ts`,
|
|
130
|
+
contents: prose
|
|
131
|
+
? `
|
|
132
|
+
export default {
|
|
133
|
+
base: ''
|
|
134
|
+
}
|
|
135
|
+
`
|
|
136
|
+
: `
|
|
137
|
+
export default {
|
|
138
|
+
slots: {
|
|
139
|
+
root: ''
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
`
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const test = ({ name, prose, content }) => {
|
|
147
|
+
const upperName = splitByCase(name).map(p => upperFirst(p)).join('')
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
filename: `test/components/${content ? 'content/' : ''}${upperName}.spec.ts`,
|
|
151
|
+
contents: prose
|
|
152
|
+
? undefined
|
|
153
|
+
: `
|
|
154
|
+
import { describe, it, expect } from 'vitest'
|
|
155
|
+
import ${upperName}, { type ${upperName}Props, type ${upperName}Slots } from '../../${content ? '../' : ''}src/runtime/components/${content ? 'content/' : ''}${upperName}.vue'
|
|
156
|
+
import ComponentRender from '../${content ? '../' : ''}component-render'
|
|
157
|
+
|
|
158
|
+
describe('${upperName}', () => {
|
|
159
|
+
it.each([
|
|
160
|
+
// Props
|
|
161
|
+
['with as', { props: { as: 'section' } }],
|
|
162
|
+
['with class', { props: { class: '' } }],
|
|
163
|
+
['with b24ui', { props: { b24ui: {} } }],
|
|
164
|
+
// Slots
|
|
165
|
+
['with default slot', { slots: { default: () => 'Default slot' } }]
|
|
166
|
+
])('renders %s correctly', async (nameOrHtml: string, options: { props?: ${upperName}Props, slots?: Partial<${upperName}Slots> }) => {
|
|
167
|
+
const html = await ComponentRender(nameOrHtml, options, ${upperName})
|
|
168
|
+
expect(html).toMatchSnapshot()
|
|
169
|
+
})
|
|
170
|
+
})
|
|
171
|
+
`
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const docs = ({ name, pro, primitive }) => {
|
|
176
|
+
const kebabName = kebabCase(name)
|
|
177
|
+
const upperName = splitByCase(name).map(p => upperFirst(p)).join('')
|
|
178
|
+
|
|
179
|
+
if (pro) {
|
|
180
|
+
// @memo for pro
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return {
|
|
184
|
+
filename: `docs/components/${kebabName}.md`,
|
|
185
|
+
contents: replaceBrackets(`---
|
|
186
|
+
title: ${upperName}
|
|
187
|
+
description: _todo_ change me
|
|
188
|
+
outline: deep
|
|
189
|
+
---
|
|
190
|
+
[[script setup]]
|
|
191
|
+
import ${upperName}Example from '/examples/${upperName.toLowerCase()}/${upperName}Example.vue';
|
|
192
|
+
[[/script]]
|
|
193
|
+
# ${upperName}
|
|
194
|
+
|
|
195
|
+
[[Description ${
|
|
196
|
+
primitive
|
|
197
|
+
? ''
|
|
198
|
+
: `
|
|
199
|
+
nuxt-ui="https://ui3.nuxt.dev/components/${kebabName}"
|
|
200
|
+
reka-ui="https://www.reka-ui.com/components/${kebabName}.html"
|
|
201
|
+
reka-ui-title="${kebabName}"`}
|
|
202
|
+
git="https://github.com/bitrix24/b24ui/blob/main/src/runtime/components/${upperName}.vue"
|
|
203
|
+
]]
|
|
204
|
+
@todo change me
|
|
205
|
+
[[/Description]]
|
|
206
|
+
|
|
207
|
+
## Usage
|
|
208
|
+
|
|
209
|
+
[[ComponentShowExample ]]
|
|
210
|
+
[[iframe data-why class="min-h-[80px]" allowtransparency="true"]]
|
|
211
|
+
[[${upperName}Example /]]
|
|
212
|
+
[[/iframe]]
|
|
213
|
+
[[/ComponentShowExample]]
|
|
214
|
+
|
|
215
|
+
<<< @/examples/${upperName.toLowerCase()}/${upperName}Example.vue
|
|
216
|
+
|
|
217
|
+
## API
|
|
218
|
+
|
|
219
|
+
### Props
|
|
220
|
+
|
|
221
|
+
[[ComponentProps component="${upperName}" /]]
|
|
222
|
+
|
|
223
|
+
### Slots
|
|
224
|
+
|
|
225
|
+
[[ComponentSlots component="${upperName}" /]]
|
|
226
|
+
|
|
227
|
+
### Emits
|
|
228
|
+
|
|
229
|
+
[[ComponentEmits component="${upperName}" /]]
|
|
230
|
+
`)
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export default {
|
|
235
|
+
playground,
|
|
236
|
+
component,
|
|
237
|
+
theme,
|
|
238
|
+
test,
|
|
239
|
+
docs
|
|
240
|
+
}
|
package/cli/utils.mjs
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { promises as fsp } from 'node:fs'
|
|
2
|
+
|
|
3
|
+
export async function sortFile(path) {
|
|
4
|
+
const file = await fsp.readFile(path, 'utf-8')
|
|
5
|
+
|
|
6
|
+
const lines = file.trim().split('\n').sort()
|
|
7
|
+
|
|
8
|
+
await fsp.writeFile(path, lines.join('\n') + '\n')
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function appendFile(path, contents) {
|
|
12
|
+
const file = await fsp.readFile(path, 'utf-8')
|
|
13
|
+
|
|
14
|
+
if (!file.includes(contents)) {
|
|
15
|
+
await fsp.writeFile(path, file.trim() + '\n' + contents + '\n')
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function normalizeLocale(locale) {
|
|
20
|
+
if (!locale) {
|
|
21
|
+
return ''
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (locale.includes('_')) {
|
|
25
|
+
return locale.split('_')
|
|
26
|
+
.map((part, index) => index === 0 ? part.toLowerCase() : part.toUpperCase())
|
|
27
|
+
.join('-')
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return locale.toLowerCase()
|
|
31
|
+
}
|