@nuxt/devtools-ui-kit 0.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/LICENSE +21 -0
- package/README.md +79 -0
- package/dist/assets/styles.css +14 -0
- package/dist/components/NButton.vue +22 -0
- package/dist/components/NCard.vue +5 -0
- package/dist/components/NCheckbox.vue +35 -0
- package/dist/components/NDarkToggle.vue +28 -0
- package/dist/components/NDialog.vue +64 -0
- package/dist/components/NDropdown.vue +31 -0
- package/dist/components/NIcon.vue +9 -0
- package/dist/components/NLink.vue +19 -0
- package/dist/components/NRadio.vue +40 -0
- package/dist/components/NSwitch.vue +37 -0
- package/dist/components/NTextInput.vue +34 -0
- package/dist/components/NTip.vue +16 -0
- package/dist/module.cjs +5 -0
- package/dist/module.d.ts +12 -0
- package/dist/module.json +5 -0
- package/dist/module.mjs +36 -0
- package/dist/types.d.ts +10 -0
- package/dist/unocss.d.ts +7 -0
- package/dist/unocss.mjs +126 -0
- package/module.cjs +6 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022-PRESENT Nuxt Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# @nuxt/devtools-ui-kit
|
|
2
|
+
|
|
3
|
+
<a href="https://www.npmjs.com/package/@nuxt/devtools-ui-kit-edge"><img src="https://flat.badgen.net/npm/v/@nuxt/devtools-ui-kit-edge"></a>
|
|
4
|
+
|
|
5
|
+
> **Warning**: This library is heavily working in progress. Breaking changes may not follow semver. Pin the version if used.
|
|
6
|
+
|
|
7
|
+
UI kit for module authors to build embedded views for Nuxt Devtools.
|
|
8
|
+
|
|
9
|
+
- [Demo](https://components.ui.nuxtjs.org)
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm i @nuxt/devtools-ui-kit
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
export default defineNuxtConfig({
|
|
19
|
+
modules: [
|
|
20
|
+
'@nuxt/devtools-ui-kit'
|
|
21
|
+
]
|
|
22
|
+
})
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
`@nuxt/devtools-ui-kit` is an unbundled component library powered by [UnoCSS](https://github.com/antfu/unocss) and [VueUse](https://vueuse.org/).
|
|
28
|
+
|
|
29
|
+
In this library, we introduced the `n` attribute for every component to customize the styles and variations. For example, to make a red button:
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<NButton n="red" />
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
to make it larger, add the size specifier (`sm`, `md`, `lg` or `xl`) the `n` attribute:
|
|
36
|
+
|
|
37
|
+
```html
|
|
38
|
+
<NButton n="red xl" />
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
You can apply the same specifiers to any other component, for example:
|
|
42
|
+
|
|
43
|
+
```html
|
|
44
|
+
<NCheckbox n="red xl" />
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Apply it to parent components could make a local theme scope
|
|
48
|
+
|
|
49
|
+
```html
|
|
50
|
+
<NCard n="green-500">
|
|
51
|
+
<!-- both of them are themed green -->
|
|
52
|
+
<NCheckbox>i accept the terms & conditions</NCheckbox>
|
|
53
|
+
<NButton>Submit</NButton>
|
|
54
|
+
</NCard>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Theming
|
|
58
|
+
|
|
59
|
+
Powered by [UnoCSS](https://github.com/antfu/unocss), you can use Tailwind/Windi CSS utilities to quickly customize the look and feel of components.
|
|
60
|
+
|
|
61
|
+
It's also possible to override the default theme globally, for example:
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
// nuxt.config.js
|
|
65
|
+
export default defineNuxtConfig({
|
|
66
|
+
modules: [
|
|
67
|
+
'@nuxt/devtools-ui-kit'
|
|
68
|
+
],
|
|
69
|
+
unocss: {
|
|
70
|
+
shortcuts: {
|
|
71
|
+
'n-button-base': 'border n-border-base rounded shadow-sm op80 !outline-none',
|
|
72
|
+
'n-button-hover': 'op100 !border-context text-context',
|
|
73
|
+
'n-button-active': 'n-active-base bg-context/5',
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
You can find all the default values and available entries in [src/unocss/index.ts](./src/unocss/index.ts).
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { NuxtLink } from '#components'
|
|
3
|
+
|
|
4
|
+
defineProps<{
|
|
5
|
+
to?: string
|
|
6
|
+
icon?: string
|
|
7
|
+
}>()
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<Component
|
|
12
|
+
:is="to ? NuxtLink : 'button'"
|
|
13
|
+
:to="to"
|
|
14
|
+
v-bind="$attrs"
|
|
15
|
+
class="n-transition n-button n-button-base hover:n-button-hover active:n-button-active focus-visible:n-focus-base n-disabled:n-disabled"
|
|
16
|
+
>
|
|
17
|
+
<slot name="icon">
|
|
18
|
+
<NIcon v-if="icon" :icon="icon" class="n-button-icon" />
|
|
19
|
+
</slot>
|
|
20
|
+
<slot />
|
|
21
|
+
</Component>
|
|
22
|
+
</template>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useVModel } from '@vueuse/core'
|
|
3
|
+
|
|
4
|
+
const props = withDefaults(
|
|
5
|
+
defineProps<{
|
|
6
|
+
modelValue?: boolean
|
|
7
|
+
disabled?: boolean }>(),
|
|
8
|
+
{
|
|
9
|
+
modelValue: false,
|
|
10
|
+
disabled: false,
|
|
11
|
+
},
|
|
12
|
+
)
|
|
13
|
+
const emit = defineEmits<{ (...args: any): void }>()
|
|
14
|
+
const checked = useVModel(props, 'modelValue', emit, { passive: true })
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<label
|
|
19
|
+
class="items-center select-none n-disabled:n-disabled n-checkbox inline-flex hover:n-checkbox-hover"
|
|
20
|
+
:checked="checked || null"
|
|
21
|
+
:disabled="disabled || null"
|
|
22
|
+
>
|
|
23
|
+
<input
|
|
24
|
+
v-model="checked"
|
|
25
|
+
type="checkbox"
|
|
26
|
+
class="absolute op0 peer"
|
|
27
|
+
:disabled="disabled"
|
|
28
|
+
@keypress.enter="checked = !checked"
|
|
29
|
+
>
|
|
30
|
+
<span class="n-transition n-checkbox-box n-checked:n-checkbox-box-checked peer-active:n-active-base peer-focus-visible:n-focus-base">
|
|
31
|
+
<NIcon class="n-transition op0 n-checkbox-icon transform scale-0 n-checked:op100 n-checked:scale-100" />
|
|
32
|
+
</span>
|
|
33
|
+
<span><slot /></span>
|
|
34
|
+
</label>
|
|
35
|
+
</template>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import { useToggle } from '@vueuse/core'
|
|
4
|
+
// @ts-expect-error auto imported from @nuxtjs/color-mode
|
|
5
|
+
import { useColorMode } from '#imports'
|
|
6
|
+
|
|
7
|
+
const mode = useColorMode()
|
|
8
|
+
const isDark = computed<boolean>({
|
|
9
|
+
get() {
|
|
10
|
+
return mode.value === 'dark'
|
|
11
|
+
},
|
|
12
|
+
set() {
|
|
13
|
+
mode.preference = isDark.value ? 'light' : 'dark'
|
|
14
|
+
},
|
|
15
|
+
})
|
|
16
|
+
const toggle = useToggle(isDark)
|
|
17
|
+
const context = {
|
|
18
|
+
mode,
|
|
19
|
+
isDark,
|
|
20
|
+
toggle,
|
|
21
|
+
}
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<template>
|
|
25
|
+
<ColorScheme tag="span">
|
|
26
|
+
<slot v-bind="context" />
|
|
27
|
+
</ColorScheme>
|
|
28
|
+
</template>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { onMounted, ref, watch } from 'vue'
|
|
3
|
+
import { useVModel } from '@vueuse/core'
|
|
4
|
+
import { useFocusTrap } from '@vueuse/integrations/useFocusTrap'
|
|
5
|
+
|
|
6
|
+
const props = withDefaults(
|
|
7
|
+
defineProps<{
|
|
8
|
+
modelValue?: boolean
|
|
9
|
+
dim?: boolean
|
|
10
|
+
}>(),
|
|
11
|
+
{
|
|
12
|
+
modelValue: false,
|
|
13
|
+
dim: true,
|
|
14
|
+
},
|
|
15
|
+
)
|
|
16
|
+
const emit = defineEmits<{
|
|
17
|
+
(event: 'close'): void
|
|
18
|
+
(event: 'update:modelValue', value: boolean): void
|
|
19
|
+
}>()
|
|
20
|
+
|
|
21
|
+
const show = useVModel(props, 'modelValue', emit, { passive: true })
|
|
22
|
+
const card = ref(null)
|
|
23
|
+
|
|
24
|
+
const { activate, deactivate } = useFocusTrap(card, { immediate: false })
|
|
25
|
+
|
|
26
|
+
onMounted(() => {
|
|
27
|
+
watch(show, (v) => {
|
|
28
|
+
if (v)
|
|
29
|
+
activate()
|
|
30
|
+
else deactivate()
|
|
31
|
+
}, { immediate: true })
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
function close() {
|
|
35
|
+
show.value = false
|
|
36
|
+
emit('close')
|
|
37
|
+
}
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<script lang="ts">
|
|
41
|
+
export default {
|
|
42
|
+
inheritAttrs: false,
|
|
43
|
+
}
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<template>
|
|
47
|
+
<div
|
|
48
|
+
class="n-transition fixed flex items-center justify-center n-dialog inset-0 z-100"
|
|
49
|
+
:class="[
|
|
50
|
+
show ? '' : 'op0 pointer-events-none',
|
|
51
|
+
]"
|
|
52
|
+
>
|
|
53
|
+
<div
|
|
54
|
+
class="absolute inset-0 -z-1"
|
|
55
|
+
:class="[
|
|
56
|
+
dim ? 'bg-black/50' : '',
|
|
57
|
+
]"
|
|
58
|
+
@click="close"
|
|
59
|
+
/>
|
|
60
|
+
<NCard v-bind="$attrs" ref="card">
|
|
61
|
+
<slot />
|
|
62
|
+
</NCard>
|
|
63
|
+
</div>
|
|
64
|
+
</template>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref } from 'vue'
|
|
3
|
+
import { onClickOutside, useVModel } from '@vueuse/core'
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{ modelValue?: boolean }>()
|
|
6
|
+
const emit = defineEmits<{ (...args: any): void }>()
|
|
7
|
+
|
|
8
|
+
const enabled = useVModel(props, 'modelValue', emit, { passive: true })
|
|
9
|
+
const el = ref<HTMLDivElement>()
|
|
10
|
+
|
|
11
|
+
onClickOutside(el, () => {
|
|
12
|
+
enabled.value = false
|
|
13
|
+
})
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<div ref="el" class="relative">
|
|
18
|
+
<slot name="trigger" :enabled="enabled" @click="enabled = !enabled">
|
|
19
|
+
<NButton @click="enabled = !enabled">
|
|
20
|
+
Dropdown
|
|
21
|
+
</NButton>
|
|
22
|
+
</slot>
|
|
23
|
+
|
|
24
|
+
<div
|
|
25
|
+
class="absolute n-transition n-bg-base rounded z-10 border n-border-base shadow"
|
|
26
|
+
:class="[enabled ? 'op-100' : 'op0 pointer-events-none -translate-y-1']"
|
|
27
|
+
>
|
|
28
|
+
<slot />
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { NuxtLink } from '#components'
|
|
3
|
+
|
|
4
|
+
defineProps<{
|
|
5
|
+
to?: string
|
|
6
|
+
href?: string
|
|
7
|
+
target?: string
|
|
8
|
+
}>()
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<template>
|
|
12
|
+
<Component
|
|
13
|
+
:is="(href || target) ? 'a' : NuxtLink"
|
|
14
|
+
v-bind="$props"
|
|
15
|
+
class="n-link n-link-base hover:n-link-hover n-transition"
|
|
16
|
+
>
|
|
17
|
+
<slot />
|
|
18
|
+
</Component>
|
|
19
|
+
</template>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useVModel } from '@vueuse/core'
|
|
3
|
+
|
|
4
|
+
const props = withDefaults(
|
|
5
|
+
defineProps<{
|
|
6
|
+
modelValue?: string
|
|
7
|
+
disabled?: boolean
|
|
8
|
+
name?: string
|
|
9
|
+
value?: string
|
|
10
|
+
}>(),
|
|
11
|
+
{
|
|
12
|
+
modelValue: '',
|
|
13
|
+
disabled: false,
|
|
14
|
+
},
|
|
15
|
+
)
|
|
16
|
+
const emit = defineEmits<{ (...args: any): void }>()
|
|
17
|
+
const model = useVModel(props, 'modelValue', emit, { passive: true })
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<label
|
|
22
|
+
class="inline-flex items-center select-none n-disabled:n-disabled n-radio hover:n-radio-hover"
|
|
23
|
+
:checked="model === value || null"
|
|
24
|
+
:disabled="disabled || null"
|
|
25
|
+
>
|
|
26
|
+
<input
|
|
27
|
+
v-model="model"
|
|
28
|
+
type="radio"
|
|
29
|
+
class="absolute op0 peer"
|
|
30
|
+
:disabled="disabled"
|
|
31
|
+
:name="name"
|
|
32
|
+
:value="value"
|
|
33
|
+
@keypress.enter="model = value"
|
|
34
|
+
>
|
|
35
|
+
<span class="n-transition peer-active:n-active-base peer-focus-visible:n-focus-base n-radio-box n-checked:n-radio-box-checked">
|
|
36
|
+
<div class="n-transition n-radio-inner n-checked:n-radio-inner-checked" />
|
|
37
|
+
</span>
|
|
38
|
+
<span><slot /></span>
|
|
39
|
+
</label>
|
|
40
|
+
</template>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useVModel } from '@vueuse/core'
|
|
3
|
+
|
|
4
|
+
const props = withDefaults(
|
|
5
|
+
defineProps<{
|
|
6
|
+
modelValue?: boolean
|
|
7
|
+
disabled?: boolean }>(),
|
|
8
|
+
{
|
|
9
|
+
modelValue: false,
|
|
10
|
+
disabled: false,
|
|
11
|
+
},
|
|
12
|
+
)
|
|
13
|
+
const emit = defineEmits<{ (...args: any): void }>()
|
|
14
|
+
const checked = useVModel(props, 'modelValue', emit, { passive: true })
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<label
|
|
19
|
+
class="n-disabled:n-disabled n-switch n-switch-base"
|
|
20
|
+
:checked="checked || null"
|
|
21
|
+
:disabled="disabled || null"
|
|
22
|
+
>
|
|
23
|
+
<input
|
|
24
|
+
v-model="checked"
|
|
25
|
+
type="checkbox"
|
|
26
|
+
class="absolute op0 peer"
|
|
27
|
+
:disabled="disabled"
|
|
28
|
+
@keypress.enter="checked = !checked"
|
|
29
|
+
>
|
|
30
|
+
<div class="n-transition peer-active:n-active-base peer-focus-visible:n-focus-base n-switch-slider n-checked:n-switch-slider-checked">
|
|
31
|
+
<div
|
|
32
|
+
class="n-transition n-switch-thumb n-checked:n-switch-thumb-checked"
|
|
33
|
+
/>
|
|
34
|
+
</div>
|
|
35
|
+
<span><slot /></span>
|
|
36
|
+
</label>
|
|
37
|
+
</template>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useVModel } from '@vueuse/core'
|
|
3
|
+
|
|
4
|
+
const props = withDefaults(
|
|
5
|
+
defineProps<{
|
|
6
|
+
modelValue?: string
|
|
7
|
+
placeholder?: string
|
|
8
|
+
icon?: string
|
|
9
|
+
disabled?: boolean
|
|
10
|
+
type?: string
|
|
11
|
+
}>(),
|
|
12
|
+
{
|
|
13
|
+
modelValue: '',
|
|
14
|
+
disabled: false,
|
|
15
|
+
type: 'text',
|
|
16
|
+
},
|
|
17
|
+
)
|
|
18
|
+
const emit = defineEmits<{ (...args: any): void }>()
|
|
19
|
+
const input = useVModel(props, 'modelValue', emit, { passive: true })
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<template>
|
|
23
|
+
<div class="n-bg-base rounded py-1 border n-border-base flex items-center flex n-text-input focus-within:n-focus-base focus-within:border-context px-2">
|
|
24
|
+
<slot name="icon">
|
|
25
|
+
<NIcon v-if="icon" :icon="icon" class="op50 mr-0.4em text-1.1em" />
|
|
26
|
+
</slot>
|
|
27
|
+
<input
|
|
28
|
+
v-model="input"
|
|
29
|
+
class="flex-auto n-bg-base w-full !outline-none"
|
|
30
|
+
:type="type"
|
|
31
|
+
:placeholder="placeholder"
|
|
32
|
+
>
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
defineProps<{
|
|
3
|
+
icon?: string
|
|
4
|
+
}>()
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<div class="n-tip n-tip-base">
|
|
9
|
+
<slot name="icon">
|
|
10
|
+
<NIcon v-if="icon" :icon="icon" class="n-tip-icon" />
|
|
11
|
+
</slot>
|
|
12
|
+
<div>
|
|
13
|
+
<slot />
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
package/dist/module.cjs
ADDED
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
export { unocssPreset } from './unocss.js';
|
|
3
|
+
import '@unocss/core';
|
|
4
|
+
import '@unocss/nuxt';
|
|
5
|
+
|
|
6
|
+
interface ModuleOptions {
|
|
7
|
+
dev?: boolean;
|
|
8
|
+
preset?: string;
|
|
9
|
+
}
|
|
10
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
|
|
11
|
+
|
|
12
|
+
export { ModuleOptions, _default as default };
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { fileURLToPath } from 'url';
|
|
2
|
+
import { defineNuxtModule, addComponentsDir, createResolver, installModule } from '@nuxt/kit';
|
|
3
|
+
import defu from 'defu';
|
|
4
|
+
import { extendUnocssOptions } from './unocss.mjs';
|
|
5
|
+
export { unocssPreset } from './unocss.mjs';
|
|
6
|
+
import '@unocss/preset-mini/utils';
|
|
7
|
+
import '@unocss/preset-mini';
|
|
8
|
+
import '@unocss/preset-mini/rules';
|
|
9
|
+
import 'unocss';
|
|
10
|
+
|
|
11
|
+
const rPath = (p) => fileURLToPath(new URL(p, import.meta.url).toString());
|
|
12
|
+
const module = defineNuxtModule({
|
|
13
|
+
meta: {
|
|
14
|
+
name: "devtools-ui-kit",
|
|
15
|
+
configKey: "devtoolsUIKit"
|
|
16
|
+
},
|
|
17
|
+
defaults: {
|
|
18
|
+
preset: rPath("./preset"),
|
|
19
|
+
dev: false
|
|
20
|
+
},
|
|
21
|
+
async setup(options, nuxt) {
|
|
22
|
+
addComponentsDir({ path: rPath("./components/nuxt") });
|
|
23
|
+
addComponentsDir({ path: rPath("./components") });
|
|
24
|
+
nuxt.options.css.unshift(rPath("assets/styles.css"));
|
|
25
|
+
if (!options.dev)
|
|
26
|
+
nuxt.options.unocss = extendUnocssOptions(nuxt.options.unocss);
|
|
27
|
+
nuxt.options.vueuse = nuxt.options.vueuse || {};
|
|
28
|
+
nuxt.options.colorMode = defu(nuxt.options.colorMode, { classSuffix: "" });
|
|
29
|
+
const resolver = createResolver(import.meta.url);
|
|
30
|
+
await installModule(await resolver.resolvePath("@unocss/nuxt"));
|
|
31
|
+
await installModule(await resolver.resolvePath("@vueuse/nuxt"));
|
|
32
|
+
await installModule(await resolver.resolvePath("@nuxtjs/color-mode"));
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export { module as default };
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
import { ModuleOptions } from './module'
|
|
3
|
+
|
|
4
|
+
declare module '@nuxt/schema' {
|
|
5
|
+
interface NuxtConfig { ['devtoolsUIKit']?: Partial<ModuleOptions> }
|
|
6
|
+
interface NuxtOptions { ['devtoolsUIKit']?: ModuleOptions }
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export { unocssPreset } from './module'
|
package/dist/unocss.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Preset } from '@unocss/core';
|
|
2
|
+
import { UnocssNuxtOptions } from '@unocss/nuxt';
|
|
3
|
+
|
|
4
|
+
declare const unocssPreset: () => Preset;
|
|
5
|
+
declare function extendUnocssOptions(user?: UnocssNuxtOptions): UnocssNuxtOptions;
|
|
6
|
+
|
|
7
|
+
export { extendUnocssOptions, unocssPreset };
|
package/dist/unocss.mjs
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { parseColor } from '@unocss/preset-mini/utils';
|
|
2
|
+
import { theme } from '@unocss/preset-mini';
|
|
3
|
+
import { fonts } from '@unocss/preset-mini/rules';
|
|
4
|
+
import { mergeDeep, presetUno, presetAttributify, presetTypography, presetIcons, transformerDirectives, transformerVariantGroup } from 'unocss';
|
|
5
|
+
|
|
6
|
+
const unocssPreset = () => ({
|
|
7
|
+
name: "@nuxt/devtools-ui-kit",
|
|
8
|
+
theme: mergeDeep(theme, {
|
|
9
|
+
colors: {
|
|
10
|
+
context: "rgba(var(--nui-c-context),%alpha)"
|
|
11
|
+
},
|
|
12
|
+
fontFamily: {
|
|
13
|
+
sans: "Avenir, Helvetica, Arial, sans-serif"
|
|
14
|
+
}
|
|
15
|
+
}),
|
|
16
|
+
rules: [
|
|
17
|
+
[/^n-(.*)$/, ([, body], { theme }) => {
|
|
18
|
+
const color = parseColor(body, theme);
|
|
19
|
+
if (color?.cssColor?.type === "rgb" && color.cssColor.components) {
|
|
20
|
+
return {
|
|
21
|
+
"--nui-c-context": `${color.cssColor.components.join(",")}`
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}],
|
|
25
|
+
[/^n-(.*)$/, fonts[1][1]],
|
|
26
|
+
["n-dashed", { "border-style": "dashed" }],
|
|
27
|
+
["n-solid", {
|
|
28
|
+
"background-color": "rgba(var(--nui-c-context), 1) !important",
|
|
29
|
+
"border-color": "rgba(var(--nui-c-context), 1)",
|
|
30
|
+
"color": "white !important"
|
|
31
|
+
}],
|
|
32
|
+
["n-disabled", {
|
|
33
|
+
"opacity": 0.4,
|
|
34
|
+
"pointer-events": "none",
|
|
35
|
+
"filter": "saturate(0)"
|
|
36
|
+
}]
|
|
37
|
+
],
|
|
38
|
+
variants: [
|
|
39
|
+
(input) => {
|
|
40
|
+
const prefix = "n-disabled:";
|
|
41
|
+
if (input.startsWith(prefix)) {
|
|
42
|
+
return {
|
|
43
|
+
matcher: input.slice(prefix.length),
|
|
44
|
+
selector: (input2) => `[disabled] ${input2}, ${input2}[disabled]`
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
(input) => {
|
|
49
|
+
const prefix = "n-checked:";
|
|
50
|
+
if (input.startsWith(prefix)) {
|
|
51
|
+
return {
|
|
52
|
+
matcher: input.slice(prefix.length),
|
|
53
|
+
selector: (input2) => `[checked] ${input2}, ${input2}[checked]`
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
shortcuts: {
|
|
59
|
+
// general
|
|
60
|
+
"n-bg-base": "bg-white dark:bg-[#151515]",
|
|
61
|
+
"n-bg-active": "bg-gray:5",
|
|
62
|
+
"n-border-base": "border-gray/20",
|
|
63
|
+
"n-transition": "transition-all duration-200",
|
|
64
|
+
"n-focus-base": "ring-2 ring-context/50",
|
|
65
|
+
"n-active-base": "ring-3 ring-context/10",
|
|
66
|
+
"n-borderless": "!border-none !shadow-none",
|
|
67
|
+
// link
|
|
68
|
+
"n-link-base": "underline underline-offset-2 underline-black/20 dark:underline-white/40",
|
|
69
|
+
"n-link-hover": "decoration-dotted text-context underline-context",
|
|
70
|
+
// card
|
|
71
|
+
"n-card-base": "border n-border-base rounded n-bg-base shadow-sm",
|
|
72
|
+
// header
|
|
73
|
+
"n-header-upper": "text-sm uppercase mb-2 leading-1.2em tracking-wide op50",
|
|
74
|
+
// button
|
|
75
|
+
"n-button-base": "border n-border-base rounded shadow-sm px-1em py-0.25em inline-flex items-center gap-1 op80 !outline-none touch-manipulation",
|
|
76
|
+
"n-button-hover": "op100 !border-context text-context",
|
|
77
|
+
"n-button-active": "n-active-base bg-context/5",
|
|
78
|
+
"n-button-icon": "-ml-0.2em mr-0.2em text-1.1em",
|
|
79
|
+
// checkbox
|
|
80
|
+
"n-checkbox-box": "border n-border-base w-1.1em h-1.1em mr-1 text-white flex flex-none items-center rounded-sm overflow-visible",
|
|
81
|
+
"n-checkbox-box-checked": "bg-context border-context",
|
|
82
|
+
"n-checkbox-icon": "carbon-checkmark",
|
|
83
|
+
// radio
|
|
84
|
+
"n-radio-box": "border n-border-base w-1.2em h-1.2em mr-1 text-white flex flex-none rounded-full overflow-visible",
|
|
85
|
+
"n-radio-box-checked": "border-context",
|
|
86
|
+
"n-radio-inner": "bg-context rounded-1/2 w-0 h-0 m-auto",
|
|
87
|
+
"n-radio-inner-checked": "w-0.8em h-0.8em",
|
|
88
|
+
// switch
|
|
89
|
+
"n-switch-base": "inline-flex items-center select-none",
|
|
90
|
+
"n-switch-slider": "mr-1 rounded-full border n-border-base relative p-2px",
|
|
91
|
+
"n-switch-slider-checked": "border-context/20 bg-context/10",
|
|
92
|
+
"n-switch-thumb": "h-1em w-1em rounded-1/2 border n-border-base ml-0 mr-0.8em",
|
|
93
|
+
"n-switch-thumb-checked": "bg-context border-context ml-0.8em mr-0",
|
|
94
|
+
// tip
|
|
95
|
+
"n-tip-base": "bg-context/8 text-context px-1em py-0.4em rounded flex items-center dark:bg-context/12",
|
|
96
|
+
"n-tip-icon": "-ml-0.2em mr-0.4em text-1.1em"
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
function extendUnocssOptions(user = {}) {
|
|
100
|
+
return {
|
|
101
|
+
...user,
|
|
102
|
+
preflight: true,
|
|
103
|
+
presets: [
|
|
104
|
+
presetUno(),
|
|
105
|
+
presetAttributify(),
|
|
106
|
+
presetTypography(),
|
|
107
|
+
presetIcons({
|
|
108
|
+
prefix: ["i-", ""],
|
|
109
|
+
scale: 1.2,
|
|
110
|
+
extraProperties: {
|
|
111
|
+
"display": "inline-block",
|
|
112
|
+
"vertical-align": "middle"
|
|
113
|
+
}
|
|
114
|
+
// ...(user?.icons || {})
|
|
115
|
+
}),
|
|
116
|
+
unocssPreset(),
|
|
117
|
+
...user.presets || []
|
|
118
|
+
],
|
|
119
|
+
transformers: [
|
|
120
|
+
transformerDirectives(),
|
|
121
|
+
transformerVariantGroup()
|
|
122
|
+
]
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export { extendUnocssOptions, unocssPreset };
|
package/module.cjs
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nuxt/devtools-ui-kit",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.2.0",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": "nuxt/devtools",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"require": "./module.cjs",
|
|
10
|
+
"import": "./dist/module.mjs"
|
|
11
|
+
},
|
|
12
|
+
"./module": {
|
|
13
|
+
"require": "./module.cjs",
|
|
14
|
+
"import": "./dist/module.mjs"
|
|
15
|
+
},
|
|
16
|
+
"./unocss": {
|
|
17
|
+
"import": "./dist/unocss.mjs"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"main": "./dist/module.mjs",
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"*.cjs"
|
|
24
|
+
],
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@iconify-json/carbon": "^1.1.15",
|
|
27
|
+
"@nuxt/kit": "^3.2.2",
|
|
28
|
+
"@nuxtjs/color-mode": "^3.2.0",
|
|
29
|
+
"@unocss/core": "^0.50.0",
|
|
30
|
+
"@unocss/nuxt": "^0.50.0",
|
|
31
|
+
"@unocss/preset-attributify": "^0.50.0",
|
|
32
|
+
"@unocss/preset-icons": "^0.50.0",
|
|
33
|
+
"@unocss/preset-mini": "^0.50.0",
|
|
34
|
+
"@unocss/reset": "^0.50.0",
|
|
35
|
+
"@vueuse/core": "^9.13.0",
|
|
36
|
+
"@vueuse/integrations": "^9.13.0",
|
|
37
|
+
"@vueuse/nuxt": "^9.13.0",
|
|
38
|
+
"defu": "^6.1.2",
|
|
39
|
+
"focus-trap": "^7.3.1",
|
|
40
|
+
"unocss": "^0.50.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"nuxt": "^3.2.2"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "nuxt-build-module",
|
|
50
|
+
"dev": "nuxi dev playground",
|
|
51
|
+
"playground:build": "nuxi generate playground"
|
|
52
|
+
}
|
|
53
|
+
}
|