@eslamdevui/ui 3.2.0-beta.2 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nuxt/ui/alert.ts +0 -5
- package/.nuxt/ui/badge.ts +0 -5
- package/.nuxt/ui/button-group.ts +0 -13
- package/.nuxt/ui/button.ts +0 -5
- package/.nuxt/ui/carousel.ts +0 -5
- package/.nuxt/ui/content-surround.ts +0 -5
- package/.nuxt/ui/dashboard-navbar.ts +0 -5
- package/.nuxt/ui/dashboard-sidebar-collapse.ts +0 -5
- package/.nuxt/ui/dashboard-sidebar-toggle.ts +0 -5
- package/.nuxt/ui/dashboard-sidebar.ts +0 -10
- package/.nuxt/ui/index.ts +1 -48
- package/.nuxt/ui/input-menu.ts +0 -9
- package/.nuxt/ui/input-number.ts +0 -5
- package/.nuxt/ui/input-tags.ts +0 -9
- package/.nuxt/ui/input.ts +0 -9
- package/.nuxt/ui/select-menu.ts +0 -9
- package/.nuxt/ui/select.ts +0 -9
- package/.nuxt/ui/textarea.ts +0 -9
- package/.nuxt/ui/toast.ts +0 -5
- package/LICENSE.md +9 -9
- package/README.md +147 -147
- package/cli/commands/make/component.mjs +95 -95
- package/cli/commands/make/index.mjs +14 -14
- package/cli/commands/make/locale.mjs +64 -64
- package/cli/index.mjs +15 -15
- package/cli/package.json +13 -13
- package/cli/templates.mjs +236 -236
- package/cli/utils.mjs +31 -31
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/Accordion.vue +36 -36
- package/dist/runtime/components/Alert.vue +46 -46
- package/dist/runtime/components/App.vue +10 -10
- package/dist/runtime/components/Avatar.vue +27 -27
- package/dist/runtime/components/AvatarGroup.vue +4 -4
- package/dist/runtime/components/Badge.vue +16 -16
- package/dist/runtime/components/Breadcrumb.vue +32 -32
- package/dist/runtime/components/Button.vue +28 -28
- package/dist/runtime/components/ButtonGroup.vue +3 -3
- package/dist/runtime/components/Calendar.vue +74 -74
- package/dist/runtime/components/Card.vue +13 -13
- package/dist/runtime/components/Carousel.vue +58 -58
- package/dist/runtime/components/ChatMessage.vue +35 -35
- package/dist/runtime/components/ChatMessages.vue +55 -55
- package/dist/runtime/components/ChatPrompt.vue +26 -26
- package/dist/runtime/components/ChatPromptSubmit.vue +10 -10
- package/dist/runtime/components/Checkbox.vue +33 -33
- package/dist/runtime/components/CheckboxGroup.vue +32 -32
- package/dist/runtime/components/Chip.vue +11 -11
- package/dist/runtime/components/Collapsible.vue +9 -9
- package/dist/runtime/components/ColorPicker.vue +30 -30
- package/dist/runtime/components/CommandPalette.vue +117 -117
- package/dist/runtime/components/Container.vue +3 -3
- package/dist/runtime/components/ContextMenu.vue +22 -22
- package/dist/runtime/components/ContextMenuContent.vue +105 -105
- package/dist/runtime/components/DashboardGroup.vue +3 -3
- package/dist/runtime/components/DashboardNavbar.vue +40 -40
- package/dist/runtime/components/DashboardPanel.vue +27 -27
- package/dist/runtime/components/DashboardResizeHandle.vue +7 -7
- package/dist/runtime/components/DashboardSearch.vue +20 -20
- package/dist/runtime/components/DashboardSearchButton.vue +43 -43
- package/dist/runtime/components/DashboardSidebar.vue +74 -74
- package/dist/runtime/components/DashboardSidebarCollapse.vue +7 -7
- package/dist/runtime/components/DashboardSidebarToggle.vue +7 -7
- package/dist/runtime/components/Drawer.vue +55 -55
- package/dist/runtime/components/DropdownMenu.vue +24 -24
- package/dist/runtime/components/DropdownMenuContent.vue +107 -107
- package/dist/runtime/components/Error.vue +22 -22
- package/dist/runtime/components/Form.vue +8 -8
- package/dist/runtime/components/FormField.vue +37 -37
- package/dist/runtime/components/Icon.vue +1 -1
- package/dist/runtime/components/Input.vue +34 -34
- package/dist/runtime/components/InputMenu.vue +163 -163
- package/dist/runtime/components/InputNumber.vue +49 -49
- package/dist/runtime/components/InputTags.vue +55 -55
- package/dist/runtime/components/Kbd.vue +5 -5
- package/dist/runtime/components/Link.vue +14 -14
- package/dist/runtime/components/LinkBase.vue +8 -8
- package/dist/runtime/components/Modal.vue +69 -69
- package/dist/runtime/components/NavigationMenu.vue +166 -166
- package/dist/runtime/components/OverlayProvider.vue +9 -9
- package/dist/runtime/components/Pagination.vue +47 -47
- package/dist/runtime/components/PinInput.vue +20 -20
- package/dist/runtime/components/Popover.vue +17 -17
- package/dist/runtime/components/Progress.vue +19 -19
- package/dist/runtime/components/RadioGroup.vue +43 -43
- package/dist/runtime/components/Select.vue +96 -96
- package/dist/runtime/components/SelectMenu.vue +130 -130
- package/dist/runtime/components/Separator.vue +15 -15
- package/dist/runtime/components/Skeleton.vue +10 -10
- package/dist/runtime/components/Slideover.vue +76 -76
- package/dist/runtime/components/Slider.vue +27 -27
- package/dist/runtime/components/Stepper.vue +51 -51
- package/dist/runtime/components/Switch.vue +33 -33
- package/dist/runtime/components/Table.vue +77 -77
- package/dist/runtime/components/Tabs.vue +37 -37
- package/dist/runtime/components/Textarea.vue +33 -33
- package/dist/runtime/components/Timeline.vue +38 -38
- package/dist/runtime/components/Toast.vue +69 -69
- package/dist/runtime/components/Toaster.vue +28 -28
- package/dist/runtime/components/Tooltip.vue +19 -19
- package/dist/runtime/components/Tree.vue +60 -60
- package/dist/runtime/components/color-mode/ColorModeAvatar.vue +2 -2
- package/dist/runtime/components/color-mode/ColorModeButton.vue +16 -16
- package/dist/runtime/components/color-mode/ColorModeImage.vue +2 -2
- package/dist/runtime/components/color-mode/ColorModeSelect.vue +19 -19
- package/dist/runtime/components/color-mode/ColorModeSwitch.vue +19 -19
- package/dist/runtime/components/content/ContentNavigation.vue +109 -109
- package/dist/runtime/components/content/ContentSearch.vue +25 -25
- package/dist/runtime/components/content/ContentSearchButton.vue +38 -38
- package/dist/runtime/components/content/ContentSearchButton.vue.d.ts +12 -12
- package/dist/runtime/components/content/ContentSurround.vue +29 -29
- package/dist/runtime/components/content/ContentSurround.vue.d.ts +59 -59
- package/dist/runtime/components/content/ContentToc.vue +68 -68
- package/dist/runtime/components/content/ContentToc.vue.d.ts +88 -88
- package/dist/runtime/components/locale/LocaleSelect.vue +20 -20
- package/dist/runtime/components/prose/A.vue +3 -3
- package/dist/runtime/components/prose/Accordion.vue +5 -5
- package/dist/runtime/components/prose/AccordionItem.vue +5 -5
- package/dist/runtime/components/prose/Badge.vue +3 -3
- package/dist/runtime/components/prose/Blockquote.vue +3 -3
- package/dist/runtime/components/prose/Callout.vue +27 -27
- package/dist/runtime/components/prose/Card.vue +43 -43
- package/dist/runtime/components/prose/CardGroup.vue +3 -3
- package/dist/runtime/components/prose/Code.vue +3 -3
- package/dist/runtime/components/prose/CodeCollapse.vue +16 -16
- package/dist/runtime/components/prose/CodeGroup.vue +15 -15
- package/dist/runtime/components/prose/CodeIcon.vue +1 -1
- package/dist/runtime/components/prose/CodePreview.vue +9 -9
- package/dist/runtime/components/prose/CodeTree.vue +61 -61
- package/dist/runtime/components/prose/Collapsible.vue +15 -15
- package/dist/runtime/components/prose/Em.vue +1 -1
- package/dist/runtime/components/prose/Field.vue +23 -23
- package/dist/runtime/components/prose/FieldGroup.vue +3 -3
- package/dist/runtime/components/prose/H1.vue +6 -6
- package/dist/runtime/components/prose/H2.vue +10 -10
- package/dist/runtime/components/prose/H3.vue +10 -10
- package/dist/runtime/components/prose/H4.vue +6 -6
- package/dist/runtime/components/prose/Hr.vue +1 -1
- package/dist/runtime/components/prose/Icon.vue +1 -1
- package/dist/runtime/components/prose/Img.vue +8 -8
- package/dist/runtime/components/prose/Kbd.vue +1 -1
- package/dist/runtime/components/prose/Li.vue +3 -3
- package/dist/runtime/components/prose/Ol.vue +3 -3
- package/dist/runtime/components/prose/P.vue +3 -3
- package/dist/runtime/components/prose/Pre.vue +20 -20
- package/dist/runtime/components/prose/Script.vue +3 -3
- package/dist/runtime/components/prose/Steps.vue +3 -3
- package/dist/runtime/components/prose/Strong.vue +3 -3
- package/dist/runtime/components/prose/Table.vue +5 -5
- package/dist/runtime/components/prose/Tabs.vue +14 -14
- package/dist/runtime/components/prose/TabsItem.vue +5 -5
- package/dist/runtime/components/prose/Tbody.vue +3 -3
- package/dist/runtime/components/prose/Td.vue +3 -3
- package/dist/runtime/components/prose/Th.vue +3 -3
- package/dist/runtime/components/prose/Thead.vue +3 -3
- package/dist/runtime/components/prose/Tr.vue +3 -3
- package/dist/runtime/components/prose/Ul.vue +3 -3
- package/dist/runtime/components/prose/callout/Caution.vue +3 -3
- package/dist/runtime/components/prose/callout/Note.vue +3 -3
- package/dist/runtime/components/prose/callout/Tip.vue +3 -3
- package/dist/runtime/components/prose/callout/Warning.vue +3 -3
- package/dist/runtime/inertia/components/Link.vue +12 -12
- package/dist/runtime/inertia/components/LinkBase.vue +15 -15
- package/dist/runtime/types/app.config.d.ts +6 -6
- package/dist/runtime/vue/components/Icon.vue +1 -1
- package/dist/runtime/vue/components/Link.vue +31 -31
- package/dist/runtime/vue/components/color-mode/ColorModeButton.vue +7 -7
- package/dist/runtime/vue/components/color-mode/ColorModeSelect.vue +7 -7
- package/dist/runtime/vue/components/color-mode/ColorModeSwitch.vue +7 -7
- package/package.json +1 -1
- package/vue-plugin.d.ts +5 -5
- package/.nuxt/ui/content/content-navigation.ts +0 -339
- package/.nuxt/ui/content/content-search-button.ts +0 -6
- package/.nuxt/ui/content/content-search.ts +0 -6
- package/.nuxt/ui/content/content-surround.ts +0 -39
- package/.nuxt/ui/content/content-toc.ts +0 -150
- package/.nuxt/ui/content/index.ts +0 -5
- package/.nuxt/ui/error.ts +0 -9
- package/.nuxt/ui/prose/a.ts +0 -6
- package/.nuxt/ui/prose/accordion-item.ts +0 -3
- package/.nuxt/ui/prose/accordion.ts +0 -6
- package/.nuxt/ui/prose/badge.ts +0 -3
- package/.nuxt/ui/prose/blockquote.ts +0 -3
- package/.nuxt/ui/prose/callout.ts +0 -129
- package/.nuxt/ui/prose/card-group.ts +0 -3
- package/.nuxt/ui/prose/card.ts +0 -119
- package/.nuxt/ui/prose/code-collapse.ts +0 -19
- package/.nuxt/ui/prose/code-group.ts +0 -13
- package/.nuxt/ui/prose/code-icon.ts +0 -66
- package/.nuxt/ui/prose/code-preview.ts +0 -14
- package/.nuxt/ui/prose/code-tree.ts +0 -28
- package/.nuxt/ui/prose/code.ts +0 -27
- package/.nuxt/ui/prose/collapsible.ts +0 -12
- package/.nuxt/ui/prose/em.ts +0 -3
- package/.nuxt/ui/prose/field-group.ts +0 -3
- package/.nuxt/ui/prose/field.ts +0 -11
- package/.nuxt/ui/prose/h1.ts +0 -6
- package/.nuxt/ui/prose/h2.ts +0 -14
- package/.nuxt/ui/prose/h3.ts +0 -14
- package/.nuxt/ui/prose/h4.ts +0 -6
- package/.nuxt/ui/prose/hr.ts +0 -3
- package/.nuxt/ui/prose/icon.ts +0 -3
- package/.nuxt/ui/prose/img.ts +0 -3
- package/.nuxt/ui/prose/index.ts +0 -41
- package/.nuxt/ui/prose/kbd.ts +0 -3
- package/.nuxt/ui/prose/li.ts +0 -3
- package/.nuxt/ui/prose/ol.ts +0 -3
- package/.nuxt/ui/prose/p.ts +0 -3
- package/.nuxt/ui/prose/pre.ts +0 -17
- package/.nuxt/ui/prose/steps.ts +0 -19
- package/.nuxt/ui/prose/strong.ts +0 -3
- package/.nuxt/ui/prose/table.ts +0 -6
- package/.nuxt/ui/prose/tabs-item.ts +0 -3
- package/.nuxt/ui/prose/tabs.ts +0 -5
- package/.nuxt/ui/prose/tbody.ts +0 -3
- package/.nuxt/ui/prose/td.ts +0 -3
- package/.nuxt/ui/prose/th.ts +0 -3
- package/.nuxt/ui/prose/thead.ts +0 -3
- package/.nuxt/ui/prose/tr.ts +0 -3
- package/.nuxt/ui/prose/ul.ts +0 -3
package/cli/templates.mjs
CHANGED
|
@@ -1,236 +1,236 @@
|
|
|
1
|
-
import { splitByCase, upperFirst, camelCase, kebabCase } from 'scule'
|
|
2
|
-
|
|
3
|
-
const playground = ({ name, pro }) => {
|
|
4
|
-
const upperName = splitByCase(name)
|
|
5
|
-
.map(p => upperFirst(p))
|
|
6
|
-
.join('')
|
|
7
|
-
const kebabName = kebabCase(name)
|
|
8
|
-
|
|
9
|
-
return {
|
|
10
|
-
filename: `playground/app/pages/components/${kebabName}.vue`,
|
|
11
|
-
contents: pro
|
|
12
|
-
? undefined
|
|
13
|
-
: `
|
|
14
|
-
<template>
|
|
15
|
-
<div>
|
|
16
|
-
<U${upperName} />
|
|
17
|
-
</div>
|
|
18
|
-
</template>
|
|
19
|
-
`
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const component = ({ name, primitive, pro, prose, content }) => {
|
|
24
|
-
const upperName = splitByCase(name)
|
|
25
|
-
.map(p => upperFirst(p))
|
|
26
|
-
.join('')
|
|
27
|
-
const camelName = camelCase(name)
|
|
28
|
-
const kebabName = kebabCase(name)
|
|
29
|
-
const key = pro ? 'uiPro' : 'ui'
|
|
30
|
-
const path = pro ? 'ui-pro' : 'ui'
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
filename: `src/runtime/components/${prose ? 'prose/' : ''}${content ? 'content/' : ''}${upperName}.vue`,
|
|
34
|
-
contents: primitive
|
|
35
|
-
? `
|
|
36
|
-
<script lang="ts">
|
|
37
|
-
import type { AppConfig } from '@nuxt/schema'
|
|
38
|
-
${pro ? `import type { ComponentConfig } from '@eslamdevui/ui'` : ''}
|
|
39
|
-
import theme from '#build/${path}/${prose ? 'prose/' : ''}${content ? 'content/' : ''}${kebabName}'
|
|
40
|
-
${!pro ? `import type { ComponentConfig } from '../types/utils'` : ''}
|
|
41
|
-
|
|
42
|
-
type ${upperName} = ComponentConfig<typeof theme, AppConfig, ${upperName}${pro ? `, '${key}'` : ''}>
|
|
43
|
-
|
|
44
|
-
export interface ${upperName}Props {
|
|
45
|
-
/**
|
|
46
|
-
* The element or component this component should render as.
|
|
47
|
-
* @defaultValue 'div'
|
|
48
|
-
*/
|
|
49
|
-
as?: any
|
|
50
|
-
class?: any
|
|
51
|
-
ui?: ${upperName}['slots']
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface ${upperName}Slots {
|
|
55
|
-
default(props?: {}): any
|
|
56
|
-
}
|
|
57
|
-
</script>
|
|
58
|
-
|
|
59
|
-
<script setup lang="ts">
|
|
60
|
-
import { computed } from 'vue'
|
|
61
|
-
import { Primitive } from 'reka-ui'
|
|
62
|
-
import { useAppConfig } from '#imports'
|
|
63
|
-
import { tv } from '../utils/tv'
|
|
64
|
-
|
|
65
|
-
const props = defineProps<${upperName}Props>()
|
|
66
|
-
defineSlots<${upperName}Slots>()
|
|
67
|
-
|
|
68
|
-
const appConfig = useAppConfig() as ${upperName}['AppConfig']
|
|
69
|
-
|
|
70
|
-
const ui = computed(() => tv({ extend: tv(theme), ...(appConfig.${pro ? 'uiPro' : 'ui'}?.${camelName} || {}) })())
|
|
71
|
-
</script>
|
|
72
|
-
|
|
73
|
-
<template>
|
|
74
|
-
<Primitive :as="as" :class="ui.root({ class: [props.ui?.root, props.class] })">
|
|
75
|
-
<slot />
|
|
76
|
-
</Primitive>
|
|
77
|
-
</template>
|
|
78
|
-
`
|
|
79
|
-
: `
|
|
80
|
-
<script lang="ts">
|
|
81
|
-
import type { ${upperName}RootProps, ${upperName}RootEmits } from 'reka-ui'
|
|
82
|
-
import type { AppConfig } from '@nuxt/schema'
|
|
83
|
-
${pro ? `import type { ComponentConfig } from '@eslamdevui/ui'` : ''}
|
|
84
|
-
import theme from '#build/${path}/${prose ? 'prose/' : ''}${content ? 'content/' : ''}${kebabName}'
|
|
85
|
-
${!pro ? `import type { ComponentConfig } from '../types/utils'` : ''}
|
|
86
|
-
|
|
87
|
-
type ${upperName} = ComponentConfig<typeof theme, AppConfig, ${upperName}${pro ? `, '${key}'` : ''}>
|
|
88
|
-
|
|
89
|
-
export interface ${upperName}Props extends Pick<${upperName}RootProps> {
|
|
90
|
-
class?: any
|
|
91
|
-
ui?: ${upperName}['slots']
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export interface ${upperName}Emits extends ${upperName}RootEmits {}
|
|
95
|
-
|
|
96
|
-
export interface ${upperName}Slots {}
|
|
97
|
-
</script>
|
|
98
|
-
|
|
99
|
-
<script setup lang="ts">
|
|
100
|
-
import { computed } from 'vue'
|
|
101
|
-
import { ${upperName}Root, useForwardPropsEmits } from 'reka-ui'
|
|
102
|
-
import { reactivePick } from '@vueuse/core'
|
|
103
|
-
import { useAppConfig } from '#imports'
|
|
104
|
-
import { tv } from '../utils/tv'
|
|
105
|
-
|
|
106
|
-
const props = defineProps<${upperName}Props>()
|
|
107
|
-
const emits = defineEmits<${upperName}Emits>()
|
|
108
|
-
const slots = defineSlots<${upperName}Slots>()
|
|
109
|
-
|
|
110
|
-
const appConfig = useAppConfig() as ${upperName}['AppConfig']
|
|
111
|
-
|
|
112
|
-
const rootProps = useForwardPropsEmits(reactivePick(props), emits)
|
|
113
|
-
|
|
114
|
-
const ui = computed(() => tv({ extend: tv(theme), ...(appConfig.${pro ? 'uiPro' : 'ui'}?.${camelName} || {}) })())
|
|
115
|
-
</script>
|
|
116
|
-
|
|
117
|
-
<template>
|
|
118
|
-
<${upperName}Root v-bind="rootProps" :class="ui.root({ class: [props.ui?.root, props.class] })" />
|
|
119
|
-
</template>
|
|
120
|
-
`
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const theme = ({ name, prose, content }) => {
|
|
125
|
-
const kebabName = kebabCase(name)
|
|
126
|
-
|
|
127
|
-
return {
|
|
128
|
-
filename: `src/theme/${prose ? 'prose/' : ''}${content ? 'content/' : ''}${kebabName}.ts`,
|
|
129
|
-
contents: prose
|
|
130
|
-
? `
|
|
131
|
-
export default {
|
|
132
|
-
base: ''
|
|
133
|
-
}
|
|
134
|
-
`
|
|
135
|
-
: `
|
|
136
|
-
export default {
|
|
137
|
-
slots: {
|
|
138
|
-
root: ''
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
`
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const test = ({ name, prose, content }) => {
|
|
146
|
-
const upperName = splitByCase(name)
|
|
147
|
-
.map(p => upperFirst(p))
|
|
148
|
-
.join('')
|
|
149
|
-
|
|
150
|
-
return {
|
|
151
|
-
filename: `test/components/${content ? 'content/' : ''}${upperName}.spec.ts`,
|
|
152
|
-
contents: prose
|
|
153
|
-
? undefined
|
|
154
|
-
: `
|
|
155
|
-
import { describe, it, expect } from 'vitest'
|
|
156
|
-
import ${upperName}, { type ${upperName}Props, type ${upperName}Slots } from '../../${content ? '../' : ''}src/runtime/components/${content ? 'content/' : ''}${upperName}.vue'
|
|
157
|
-
import ComponentRender from '../${content ? '../' : ''}component-render'
|
|
158
|
-
|
|
159
|
-
describe('${upperName}', () => {
|
|
160
|
-
it.each([
|
|
161
|
-
// Props
|
|
162
|
-
['with as', { props: { as: 'section' } }],
|
|
163
|
-
['with class', { props: { class: '' } }],
|
|
164
|
-
['with ui', { props: { ui: {} } }],
|
|
165
|
-
// Slots
|
|
166
|
-
['with default slot', { slots: { default: () => 'Default slot' } }]
|
|
167
|
-
])('renders %s correctly', async (nameOrHtml: string, options: { props?: ${upperName}Props, slots?: Partial<${upperName}Slots> }) => {
|
|
168
|
-
const html = await ComponentRender(nameOrHtml, options, ${upperName})
|
|
169
|
-
expect(html).toMatchSnapshot()
|
|
170
|
-
})
|
|
171
|
-
})
|
|
172
|
-
`
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const docs = ({ name, pro, primitive }) => {
|
|
177
|
-
const kebabName = kebabCase(name)
|
|
178
|
-
const upperName = splitByCase(name)
|
|
179
|
-
.map(p => upperFirst(p))
|
|
180
|
-
.join('')
|
|
181
|
-
|
|
182
|
-
return {
|
|
183
|
-
filename: `docs/content/3.components/${kebabName}.md`,
|
|
184
|
-
contents: `---
|
|
185
|
-
title: ${upperName}
|
|
186
|
-
description: ''${
|
|
187
|
-
pro
|
|
188
|
-
? `
|
|
189
|
-
module: ui-pro`
|
|
190
|
-
: ''
|
|
191
|
-
}
|
|
192
|
-
links:${
|
|
193
|
-
primitive
|
|
194
|
-
? ''
|
|
195
|
-
: `
|
|
196
|
-
- label: ${upperName}
|
|
197
|
-
icon: i-custom-reka-ui
|
|
198
|
-
to: https://reka-ui.com/docs/components/${kebabName}`
|
|
199
|
-
}
|
|
200
|
-
- label: GitHub
|
|
201
|
-
icon: i-simple-icons-github
|
|
202
|
-
to: https://github.com/MohamedEslam04/${pro ? 'ui-pro' : 'ui'}/tree/v3/src/runtime/components/${upperName}.vue
|
|
203
|
-
---
|
|
204
|
-
|
|
205
|
-
## Usage
|
|
206
|
-
|
|
207
|
-
## Examples
|
|
208
|
-
|
|
209
|
-
## API
|
|
210
|
-
|
|
211
|
-
### Props
|
|
212
|
-
|
|
213
|
-
:component-props${pro ? '{pro}' : ''}
|
|
214
|
-
|
|
215
|
-
### Slots
|
|
216
|
-
|
|
217
|
-
:component-slots${pro ? '{pro}' : ''}
|
|
218
|
-
|
|
219
|
-
### Emits
|
|
220
|
-
|
|
221
|
-
:component-emits${pro ? '{pro}' : ''}
|
|
222
|
-
|
|
223
|
-
## Theme
|
|
224
|
-
|
|
225
|
-
:component-theme${pro ? '{pro}' : ''}
|
|
226
|
-
`
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
export default {
|
|
231
|
-
playground,
|
|
232
|
-
component,
|
|
233
|
-
theme,
|
|
234
|
-
test,
|
|
235
|
-
docs
|
|
236
|
-
}
|
|
1
|
+
import { splitByCase, upperFirst, camelCase, kebabCase } from 'scule'
|
|
2
|
+
|
|
3
|
+
const playground = ({ name, pro }) => {
|
|
4
|
+
const upperName = splitByCase(name)
|
|
5
|
+
.map(p => upperFirst(p))
|
|
6
|
+
.join('')
|
|
7
|
+
const kebabName = kebabCase(name)
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
filename: `playground/app/pages/components/${kebabName}.vue`,
|
|
11
|
+
contents: pro
|
|
12
|
+
? undefined
|
|
13
|
+
: `
|
|
14
|
+
<template>
|
|
15
|
+
<div>
|
|
16
|
+
<U${upperName} />
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
`
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const component = ({ name, primitive, pro, prose, content }) => {
|
|
24
|
+
const upperName = splitByCase(name)
|
|
25
|
+
.map(p => upperFirst(p))
|
|
26
|
+
.join('')
|
|
27
|
+
const camelName = camelCase(name)
|
|
28
|
+
const kebabName = kebabCase(name)
|
|
29
|
+
const key = pro ? 'uiPro' : 'ui'
|
|
30
|
+
const path = pro ? 'ui-pro' : 'ui'
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
filename: `src/runtime/components/${prose ? 'prose/' : ''}${content ? 'content/' : ''}${upperName}.vue`,
|
|
34
|
+
contents: primitive
|
|
35
|
+
? `
|
|
36
|
+
<script lang="ts">
|
|
37
|
+
import type { AppConfig } from '@nuxt/schema'
|
|
38
|
+
${pro ? `import type { ComponentConfig } from '@eslamdevui/ui'` : ''}
|
|
39
|
+
import theme from '#build/${path}/${prose ? 'prose/' : ''}${content ? 'content/' : ''}${kebabName}'
|
|
40
|
+
${!pro ? `import type { ComponentConfig } from '../types/utils'` : ''}
|
|
41
|
+
|
|
42
|
+
type ${upperName} = ComponentConfig<typeof theme, AppConfig, ${upperName}${pro ? `, '${key}'` : ''}>
|
|
43
|
+
|
|
44
|
+
export interface ${upperName}Props {
|
|
45
|
+
/**
|
|
46
|
+
* The element or component this component should render as.
|
|
47
|
+
* @defaultValue 'div'
|
|
48
|
+
*/
|
|
49
|
+
as?: any
|
|
50
|
+
class?: any
|
|
51
|
+
ui?: ${upperName}['slots']
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface ${upperName}Slots {
|
|
55
|
+
default(props?: {}): any
|
|
56
|
+
}
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<script setup lang="ts">
|
|
60
|
+
import { computed } from 'vue'
|
|
61
|
+
import { Primitive } from 'reka-ui'
|
|
62
|
+
import { useAppConfig } from '#imports'
|
|
63
|
+
import { tv } from '../utils/tv'
|
|
64
|
+
|
|
65
|
+
const props = defineProps<${upperName}Props>()
|
|
66
|
+
defineSlots<${upperName}Slots>()
|
|
67
|
+
|
|
68
|
+
const appConfig = useAppConfig() as ${upperName}['AppConfig']
|
|
69
|
+
|
|
70
|
+
const ui = computed(() => tv({ extend: tv(theme), ...(appConfig.${pro ? 'uiPro' : 'ui'}?.${camelName} || {}) })())
|
|
71
|
+
</script>
|
|
72
|
+
|
|
73
|
+
<template>
|
|
74
|
+
<Primitive :as="as" :class="ui.root({ class: [props.ui?.root, props.class] })">
|
|
75
|
+
<slot />
|
|
76
|
+
</Primitive>
|
|
77
|
+
</template>
|
|
78
|
+
`
|
|
79
|
+
: `
|
|
80
|
+
<script lang="ts">
|
|
81
|
+
import type { ${upperName}RootProps, ${upperName}RootEmits } from 'reka-ui'
|
|
82
|
+
import type { AppConfig } from '@nuxt/schema'
|
|
83
|
+
${pro ? `import type { ComponentConfig } from '@eslamdevui/ui'` : ''}
|
|
84
|
+
import theme from '#build/${path}/${prose ? 'prose/' : ''}${content ? 'content/' : ''}${kebabName}'
|
|
85
|
+
${!pro ? `import type { ComponentConfig } from '../types/utils'` : ''}
|
|
86
|
+
|
|
87
|
+
type ${upperName} = ComponentConfig<typeof theme, AppConfig, ${upperName}${pro ? `, '${key}'` : ''}>
|
|
88
|
+
|
|
89
|
+
export interface ${upperName}Props extends Pick<${upperName}RootProps> {
|
|
90
|
+
class?: any
|
|
91
|
+
ui?: ${upperName}['slots']
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface ${upperName}Emits extends ${upperName}RootEmits {}
|
|
95
|
+
|
|
96
|
+
export interface ${upperName}Slots {}
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
<script setup lang="ts">
|
|
100
|
+
import { computed } from 'vue'
|
|
101
|
+
import { ${upperName}Root, useForwardPropsEmits } from 'reka-ui'
|
|
102
|
+
import { reactivePick } from '@vueuse/core'
|
|
103
|
+
import { useAppConfig } from '#imports'
|
|
104
|
+
import { tv } from '../utils/tv'
|
|
105
|
+
|
|
106
|
+
const props = defineProps<${upperName}Props>()
|
|
107
|
+
const emits = defineEmits<${upperName}Emits>()
|
|
108
|
+
const slots = defineSlots<${upperName}Slots>()
|
|
109
|
+
|
|
110
|
+
const appConfig = useAppConfig() as ${upperName}['AppConfig']
|
|
111
|
+
|
|
112
|
+
const rootProps = useForwardPropsEmits(reactivePick(props), emits)
|
|
113
|
+
|
|
114
|
+
const ui = computed(() => tv({ extend: tv(theme), ...(appConfig.${pro ? 'uiPro' : 'ui'}?.${camelName} || {}) })())
|
|
115
|
+
</script>
|
|
116
|
+
|
|
117
|
+
<template>
|
|
118
|
+
<${upperName}Root v-bind="rootProps" :class="ui.root({ class: [props.ui?.root, props.class] })" />
|
|
119
|
+
</template>
|
|
120
|
+
`
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const theme = ({ name, prose, content }) => {
|
|
125
|
+
const kebabName = kebabCase(name)
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
filename: `src/theme/${prose ? 'prose/' : ''}${content ? 'content/' : ''}${kebabName}.ts`,
|
|
129
|
+
contents: prose
|
|
130
|
+
? `
|
|
131
|
+
export default {
|
|
132
|
+
base: ''
|
|
133
|
+
}
|
|
134
|
+
`
|
|
135
|
+
: `
|
|
136
|
+
export default {
|
|
137
|
+
slots: {
|
|
138
|
+
root: ''
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
`
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const test = ({ name, prose, content }) => {
|
|
146
|
+
const upperName = splitByCase(name)
|
|
147
|
+
.map(p => upperFirst(p))
|
|
148
|
+
.join('')
|
|
149
|
+
|
|
150
|
+
return {
|
|
151
|
+
filename: `test/components/${content ? 'content/' : ''}${upperName}.spec.ts`,
|
|
152
|
+
contents: prose
|
|
153
|
+
? undefined
|
|
154
|
+
: `
|
|
155
|
+
import { describe, it, expect } from 'vitest'
|
|
156
|
+
import ${upperName}, { type ${upperName}Props, type ${upperName}Slots } from '../../${content ? '../' : ''}src/runtime/components/${content ? 'content/' : ''}${upperName}.vue'
|
|
157
|
+
import ComponentRender from '../${content ? '../' : ''}component-render'
|
|
158
|
+
|
|
159
|
+
describe('${upperName}', () => {
|
|
160
|
+
it.each([
|
|
161
|
+
// Props
|
|
162
|
+
['with as', { props: { as: 'section' } }],
|
|
163
|
+
['with class', { props: { class: '' } }],
|
|
164
|
+
['with ui', { props: { ui: {} } }],
|
|
165
|
+
// Slots
|
|
166
|
+
['with default slot', { slots: { default: () => 'Default slot' } }]
|
|
167
|
+
])('renders %s correctly', async (nameOrHtml: string, options: { props?: ${upperName}Props, slots?: Partial<${upperName}Slots> }) => {
|
|
168
|
+
const html = await ComponentRender(nameOrHtml, options, ${upperName})
|
|
169
|
+
expect(html).toMatchSnapshot()
|
|
170
|
+
})
|
|
171
|
+
})
|
|
172
|
+
`
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const docs = ({ name, pro, primitive }) => {
|
|
177
|
+
const kebabName = kebabCase(name)
|
|
178
|
+
const upperName = splitByCase(name)
|
|
179
|
+
.map(p => upperFirst(p))
|
|
180
|
+
.join('')
|
|
181
|
+
|
|
182
|
+
return {
|
|
183
|
+
filename: `docs/content/3.components/${kebabName}.md`,
|
|
184
|
+
contents: `---
|
|
185
|
+
title: ${upperName}
|
|
186
|
+
description: ''${
|
|
187
|
+
pro
|
|
188
|
+
? `
|
|
189
|
+
module: ui-pro`
|
|
190
|
+
: ''
|
|
191
|
+
}
|
|
192
|
+
links:${
|
|
193
|
+
primitive
|
|
194
|
+
? ''
|
|
195
|
+
: `
|
|
196
|
+
- label: ${upperName}
|
|
197
|
+
icon: i-custom-reka-ui
|
|
198
|
+
to: https://reka-ui.com/docs/components/${kebabName}`
|
|
199
|
+
}
|
|
200
|
+
- label: GitHub
|
|
201
|
+
icon: i-simple-icons-github
|
|
202
|
+
to: https://github.com/MohamedEslam04/${pro ? 'ui-pro' : 'ui'}/tree/v3/src/runtime/components/${upperName}.vue
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Usage
|
|
206
|
+
|
|
207
|
+
## Examples
|
|
208
|
+
|
|
209
|
+
## API
|
|
210
|
+
|
|
211
|
+
### Props
|
|
212
|
+
|
|
213
|
+
:component-props${pro ? '{pro}' : ''}
|
|
214
|
+
|
|
215
|
+
### Slots
|
|
216
|
+
|
|
217
|
+
:component-slots${pro ? '{pro}' : ''}
|
|
218
|
+
|
|
219
|
+
### Emits
|
|
220
|
+
|
|
221
|
+
:component-emits${pro ? '{pro}' : ''}
|
|
222
|
+
|
|
223
|
+
## Theme
|
|
224
|
+
|
|
225
|
+
:component-theme${pro ? '{pro}' : ''}
|
|
226
|
+
`
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export default {
|
|
231
|
+
playground,
|
|
232
|
+
component,
|
|
233
|
+
theme,
|
|
234
|
+
test,
|
|
235
|
+
docs
|
|
236
|
+
}
|
package/cli/utils.mjs
CHANGED
|
@@ -1,31 +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
|
-
}
|
|
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
|
+
}
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -34,40 +34,40 @@ const ui = computed(() => tv({ extend: tv(theme), ...appConfig.ui?.accordion ||
|
|
|
34
34
|
</script>
|
|
35
35
|
|
|
36
36
|
<template>
|
|
37
|
-
<AccordionRoot v-bind="rootProps" :class="ui.root({ class: [props.ui?.root, props.class] })">
|
|
38
|
-
<AccordionItem
|
|
39
|
-
v-for="(item, index) in props.items"
|
|
40
|
-
v-slot="{ open }"
|
|
41
|
-
:key="index"
|
|
42
|
-
:value="item.value || String(index)"
|
|
43
|
-
:disabled="item.disabled"
|
|
44
|
-
:class="ui.item({ class: [props.ui?.item, item.ui?.item, item.class] })"
|
|
45
|
-
>
|
|
46
|
-
<AccordionHeader as="div" :class="ui.header({ class: [props.ui?.header, item.ui?.header] })">
|
|
47
|
-
<AccordionTrigger :class="ui.trigger({ class: [props.ui?.trigger, item.ui?.trigger], disabled: item.disabled })">
|
|
48
|
-
<slot name="leading" :item="item" :index="index" :open="open">
|
|
49
|
-
<UIcon v-if="item.icon" :name="item.icon" :class="ui.leadingIcon({ class: [props.ui?.leadingIcon, item?.ui?.leadingIcon] })" />
|
|
50
|
-
</slot>
|
|
51
|
-
|
|
52
|
-
<span v-if="get(item, props.labelKey) || !!slots.default" :class="ui.label({ class: [props.ui?.label, item.ui?.label] })">
|
|
53
|
-
<slot :item="item" :index="index" :open="open">{{ get(item, props.labelKey) }}</slot>
|
|
54
|
-
</span>
|
|
55
|
-
|
|
56
|
-
<slot name="trailing" :item="item" :index="index" :open="open">
|
|
57
|
-
<UIcon :name="item.trailingIcon || trailingIcon || appConfig.ui.icons.chevronDown" :class="ui.trailingIcon({ class: [props.ui?.trailingIcon, item.ui?.trailingIcon] })" />
|
|
58
|
-
</slot>
|
|
59
|
-
</AccordionTrigger>
|
|
60
|
-
</AccordionHeader>
|
|
61
|
-
|
|
62
|
-
<AccordionContent v-if="item.content || !!slots.content || item.slot && !!slots[item.slot] || !!slots.body || item.slot && !!slots[`${item.slot}-body`]" :class="ui.content({ class: [props.ui?.content, item.ui?.content] })">
|
|
63
|
-
<slot :name="item.slot || 'content'" :item="item" :index="index" :open="open">
|
|
64
|
-
<div :class="ui.body({ class: [props.ui?.body, item.ui?.body] })">
|
|
65
|
-
<slot :name="item.slot ? `${item.slot}-body` : 'body'" :item="item" :index="index" :open="open">
|
|
66
|
-
{{ item.content }}
|
|
67
|
-
</slot>
|
|
68
|
-
</div>
|
|
69
|
-
</slot>
|
|
70
|
-
</AccordionContent>
|
|
71
|
-
</AccordionItem>
|
|
72
|
-
</AccordionRoot>
|
|
37
|
+
<AccordionRoot v-bind="rootProps" :class="ui.root({ class: [props.ui?.root, props.class] })">
|
|
38
|
+
<AccordionItem
|
|
39
|
+
v-for="(item, index) in props.items"
|
|
40
|
+
v-slot="{ open }"
|
|
41
|
+
:key="index"
|
|
42
|
+
:value="item.value || String(index)"
|
|
43
|
+
:disabled="item.disabled"
|
|
44
|
+
:class="ui.item({ class: [props.ui?.item, item.ui?.item, item.class] })"
|
|
45
|
+
>
|
|
46
|
+
<AccordionHeader as="div" :class="ui.header({ class: [props.ui?.header, item.ui?.header] })">
|
|
47
|
+
<AccordionTrigger :class="ui.trigger({ class: [props.ui?.trigger, item.ui?.trigger], disabled: item.disabled })">
|
|
48
|
+
<slot name="leading" :item="item" :index="index" :open="open">
|
|
49
|
+
<UIcon v-if="item.icon" :name="item.icon" :class="ui.leadingIcon({ class: [props.ui?.leadingIcon, item?.ui?.leadingIcon] })" />
|
|
50
|
+
</slot>
|
|
51
|
+
|
|
52
|
+
<span v-if="get(item, props.labelKey) || !!slots.default" :class="ui.label({ class: [props.ui?.label, item.ui?.label] })">
|
|
53
|
+
<slot :item="item" :index="index" :open="open">{{ get(item, props.labelKey) }}</slot>
|
|
54
|
+
</span>
|
|
55
|
+
|
|
56
|
+
<slot name="trailing" :item="item" :index="index" :open="open">
|
|
57
|
+
<UIcon :name="item.trailingIcon || trailingIcon || appConfig.ui.icons.chevronDown" :class="ui.trailingIcon({ class: [props.ui?.trailingIcon, item.ui?.trailingIcon] })" />
|
|
58
|
+
</slot>
|
|
59
|
+
</AccordionTrigger>
|
|
60
|
+
</AccordionHeader>
|
|
61
|
+
|
|
62
|
+
<AccordionContent v-if="item.content || !!slots.content || item.slot && !!slots[item.slot] || !!slots.body || item.slot && !!slots[`${item.slot}-body`]" :class="ui.content({ class: [props.ui?.content, item.ui?.content] })">
|
|
63
|
+
<slot :name="item.slot || 'content'" :item="item" :index="index" :open="open">
|
|
64
|
+
<div :class="ui.body({ class: [props.ui?.body, item.ui?.body] })">
|
|
65
|
+
<slot :name="item.slot ? `${item.slot}-body` : 'body'" :item="item" :index="index" :open="open">
|
|
66
|
+
{{ item.content }}
|
|
67
|
+
</slot>
|
|
68
|
+
</div>
|
|
69
|
+
</slot>
|
|
70
|
+
</AccordionContent>
|
|
71
|
+
</AccordionItem>
|
|
72
|
+
</AccordionRoot>
|
|
73
73
|
</template>
|