@nuxt/ui 0.0.0-alpha.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 +47 -0
- package/dist/components/NButton.vue +19 -0
- package/dist/components/NCard.vue +5 -0
- package/dist/components/NCheckbox.vue +35 -0
- package/dist/components/NDialog.vue +62 -0
- package/dist/components/NIcon.vue +9 -0
- package/dist/components/NRadio.vue +40 -0
- package/dist/components/NSwitch.vue +37 -0
- package/dist/components/NTextInput.vue +32 -0
- package/dist/components/NTip.vue +16 -0
- package/dist/nuxt.cjs +145 -0
- package/dist/nuxt.d.ts +13 -0
- package/dist/nuxt.mjs +135 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 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,47 @@
|
|
|
1
|
+
# Nuxt UI
|
|
2
|
+
|
|
3
|
+
## Install
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
# npm
|
|
7
|
+
npm install @nuxt/ui@npm:@nuxt/ui-edge
|
|
8
|
+
|
|
9
|
+
# yarn
|
|
10
|
+
yarn install @nuxt/ui@npm:@nuxt/ui-edge
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
## Components
|
|
16
|
+
|
|
17
|
+
### Base
|
|
18
|
+
|
|
19
|
+
- [ ] `<NCard>`
|
|
20
|
+
- [ ] `<NInput>`
|
|
21
|
+
- [ ] `<NCheckbox>`
|
|
22
|
+
- [ ] `<NRadio>`
|
|
23
|
+
- [ ] `<NIcon>`
|
|
24
|
+
- [ ] `<NButton>`
|
|
25
|
+
- [ ] `<NButtonGroup>`
|
|
26
|
+
- [ ] `<NSpinner>`
|
|
27
|
+
- [ ] `<NAlert>`
|
|
28
|
+
- [ ] `<NBadge>`
|
|
29
|
+
|
|
30
|
+
### Interactive
|
|
31
|
+
|
|
32
|
+
- [ ] `<NTabs>`
|
|
33
|
+
- [ ] `<NDropdown>`
|
|
34
|
+
- [ ] `<NPopup>`
|
|
35
|
+
- [ ] `<NNotification>`
|
|
36
|
+
- [ ] `<NModal>`
|
|
37
|
+
|
|
38
|
+
### Layout
|
|
39
|
+
|
|
40
|
+
- [ ] `<NContainer>`
|
|
41
|
+
- [ ] `<NDrawer>`
|
|
42
|
+
- [ ] `<NNavbar>`
|
|
43
|
+
- [ ] `<NPagination>`
|
|
44
|
+
|
|
45
|
+
## License
|
|
46
|
+
|
|
47
|
+
MIT
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Component
|
|
3
|
+
:is="to ? 'a' : 'button'"
|
|
4
|
+
:href="to"
|
|
5
|
+
class="n-button n-transition n-button-base hover:n-button-hover active:n-button-active focus-visible:n-focus-base n-disabled:n-disabled"
|
|
6
|
+
>
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<NIcon v-if="icon" :icon="icon" class="n-button-icon" />
|
|
9
|
+
</slot>
|
|
10
|
+
<slot />
|
|
11
|
+
</Component>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script setup lang="ts">
|
|
15
|
+
defineProps<{
|
|
16
|
+
to?: string
|
|
17
|
+
icon?: string
|
|
18
|
+
}>()
|
|
19
|
+
</script>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<label
|
|
3
|
+
class="n-checkbox inline-flex items-center select-none hover:n-checkbox-hover n-disabled:n-disabled"
|
|
4
|
+
:checked="checked || null"
|
|
5
|
+
:disabled="disabled || null"
|
|
6
|
+
>
|
|
7
|
+
<input
|
|
8
|
+
v-model="checked"
|
|
9
|
+
type="checkbox"
|
|
10
|
+
class="absolute op0 peer"
|
|
11
|
+
:disabled="disabled"
|
|
12
|
+
@keypress.enter="checked = !checked"
|
|
13
|
+
>
|
|
14
|
+
<span class="n-transition n-checkbox-box n-checked:n-checkbox-box-checked peer-active:n-active-base peer-focus-visible:n-focus-base">
|
|
15
|
+
<NIcon class="n-transition n-checkbox-icon transform scale-0 op0 n-checked:op100 n-checked:scale-100" />
|
|
16
|
+
</span>
|
|
17
|
+
<span><slot /></span>
|
|
18
|
+
</label>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script setup lang="ts">
|
|
22
|
+
import { useVModel } from '@vueuse/core'
|
|
23
|
+
|
|
24
|
+
const props = withDefaults(
|
|
25
|
+
defineProps<{
|
|
26
|
+
modelValue?: boolean
|
|
27
|
+
disabled?: boolean }>(),
|
|
28
|
+
{
|
|
29
|
+
modelValue: false,
|
|
30
|
+
disabled: false,
|
|
31
|
+
},
|
|
32
|
+
)
|
|
33
|
+
const emit = defineEmits<{(...args: any): void}>()
|
|
34
|
+
const checked = useVModel(props, 'modelValue', emit, { passive: true })
|
|
35
|
+
</script>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="n-dialog n-transition fixed inset-0 flex items-center justify-center z-100"
|
|
4
|
+
:class="[
|
|
5
|
+
show ? '' : 'op0 pointer-events-none',
|
|
6
|
+
]"
|
|
7
|
+
>
|
|
8
|
+
<div
|
|
9
|
+
class="absolute inset-0 -z-1"
|
|
10
|
+
:class="[
|
|
11
|
+
dim ? 'bg-black/50' : ''
|
|
12
|
+
]"
|
|
13
|
+
@click="close"
|
|
14
|
+
/>
|
|
15
|
+
<NCard v-bind="$attrs" ref="card">
|
|
16
|
+
<slot />
|
|
17
|
+
</NCard>
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script setup lang="ts">
|
|
22
|
+
import { ref, watch, onMounted } from 'vue'
|
|
23
|
+
import { useVModel } from '@vueuse/core'
|
|
24
|
+
import { useFocusTrap } from '@vueuse/integrations/useFocusTrap'
|
|
25
|
+
|
|
26
|
+
const props = withDefaults(
|
|
27
|
+
defineProps<{
|
|
28
|
+
modelValue?: boolean
|
|
29
|
+
dim?: boolean
|
|
30
|
+
}>(),
|
|
31
|
+
{
|
|
32
|
+
modelValue: false,
|
|
33
|
+
dim: true,
|
|
34
|
+
},
|
|
35
|
+
)
|
|
36
|
+
const emit = defineEmits<{ (...args: any): void }>()
|
|
37
|
+
|
|
38
|
+
const show = useVModel(props, 'modelValue', emit, { passive: true })
|
|
39
|
+
const card = ref(null)
|
|
40
|
+
|
|
41
|
+
const { activate, deactivate } = useFocusTrap(card, { immediate: false })
|
|
42
|
+
|
|
43
|
+
onMounted(() => {
|
|
44
|
+
watch(show, (v) => {
|
|
45
|
+
if (v)
|
|
46
|
+
activate()
|
|
47
|
+
else
|
|
48
|
+
deactivate()
|
|
49
|
+
}, { immediate: true })
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
function close() {
|
|
53
|
+
show.value = false
|
|
54
|
+
emit('close')
|
|
55
|
+
}
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<script lang="ts">
|
|
59
|
+
export default {
|
|
60
|
+
inheritAttrs: false,
|
|
61
|
+
}
|
|
62
|
+
</script>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<label
|
|
3
|
+
class="n-radio inline-flex items-center select-none hover:n-radio-hover n-disabled:n-disabled"
|
|
4
|
+
:checked="model === value || null"
|
|
5
|
+
:disabled="disabled || null"
|
|
6
|
+
>
|
|
7
|
+
<input
|
|
8
|
+
v-model="model"
|
|
9
|
+
type="radio"
|
|
10
|
+
class="absolute op0 peer"
|
|
11
|
+
:disabled="disabled"
|
|
12
|
+
:name="name"
|
|
13
|
+
:value="value"
|
|
14
|
+
@keypress.enter="model = value"
|
|
15
|
+
>
|
|
16
|
+
<span class="n-transition n-radio-box n-checked:n-radio-box-checked peer-active:n-active-base peer-focus-visible:n-focus-base">
|
|
17
|
+
<div class="n-transition n-radio-inner n-checked:n-radio-inner-checked" />
|
|
18
|
+
</span>
|
|
19
|
+
<span><slot /></span>
|
|
20
|
+
</label>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script setup lang="ts">
|
|
24
|
+
import { useVModel } from '@vueuse/core'
|
|
25
|
+
|
|
26
|
+
const props = withDefaults(
|
|
27
|
+
defineProps<{
|
|
28
|
+
modelValue?: string
|
|
29
|
+
disabled?: boolean
|
|
30
|
+
name?: string
|
|
31
|
+
value?: string
|
|
32
|
+
}>(),
|
|
33
|
+
{
|
|
34
|
+
modelValue: '',
|
|
35
|
+
disabled: false,
|
|
36
|
+
},
|
|
37
|
+
)
|
|
38
|
+
const emit = defineEmits<{(...args: any): void}>()
|
|
39
|
+
const model = useVModel(props, 'modelValue', emit, { passive: true })
|
|
40
|
+
</script>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<label
|
|
3
|
+
class="n-switch n-switch-base n-disabled:n-disabled"
|
|
4
|
+
:checked="checked || null"
|
|
5
|
+
:disabled="disabled || null"
|
|
6
|
+
>
|
|
7
|
+
<input
|
|
8
|
+
v-model="checked"
|
|
9
|
+
type="checkbox"
|
|
10
|
+
class="absolute op0 peer"
|
|
11
|
+
:disabled="disabled"
|
|
12
|
+
@keypress.enter="checked = !checked"
|
|
13
|
+
>
|
|
14
|
+
<div class="n-transition n-switch-slider n-checked:n-switch-slider-checked peer-active:n-active-base peer-focus-visible:n-focus-base">
|
|
15
|
+
<div
|
|
16
|
+
class="n-transition n-switch-thumb n-checked:n-switch-thumb-checked"
|
|
17
|
+
/>
|
|
18
|
+
</div>
|
|
19
|
+
<span><slot /></span>
|
|
20
|
+
</label>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script setup lang="ts">
|
|
24
|
+
import { useVModel } from '@vueuse/core'
|
|
25
|
+
|
|
26
|
+
const props = withDefaults(
|
|
27
|
+
defineProps<{
|
|
28
|
+
modelValue?: boolean
|
|
29
|
+
disabled?: boolean }>(),
|
|
30
|
+
{
|
|
31
|
+
modelValue: false,
|
|
32
|
+
disabled: false,
|
|
33
|
+
},
|
|
34
|
+
)
|
|
35
|
+
const emit = defineEmits<{(...args: any): void}>()
|
|
36
|
+
const checked = useVModel(props, 'modelValue', emit, { passive: true })
|
|
37
|
+
</script>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="n-text-input n-bg-base focus-within:n-focus-base focus-within:border-context rounded px-2 py-1 border n-border-base flex items-center flex">
|
|
3
|
+
<slot name="icon">
|
|
4
|
+
<NIcon v-if="icon" :icon="icon" class="mr-0.4em text-1.1em op50" />
|
|
5
|
+
</slot>
|
|
6
|
+
<input
|
|
7
|
+
v-model="input"
|
|
8
|
+
class="!outline-none flex-auto n-bg-base"
|
|
9
|
+
type="text"
|
|
10
|
+
:placeholder="placeholder"
|
|
11
|
+
>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
import { useVModel } from '@vueuse/core'
|
|
17
|
+
|
|
18
|
+
const props = withDefaults(
|
|
19
|
+
defineProps<{
|
|
20
|
+
modelValue?: string
|
|
21
|
+
placeholder?: string
|
|
22
|
+
icon?: string
|
|
23
|
+
disabled?: boolean
|
|
24
|
+
}>(),
|
|
25
|
+
{
|
|
26
|
+
modelValue: '',
|
|
27
|
+
disabled: false,
|
|
28
|
+
},
|
|
29
|
+
)
|
|
30
|
+
const emit = defineEmits<{(...args: any): void}>()
|
|
31
|
+
const input = useVModel(props, 'modelValue', emit, { passive: true })
|
|
32
|
+
</script>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="n-tip n-tip-base">
|
|
3
|
+
<slot name="icon">
|
|
4
|
+
<NIcon v-if="icon" :icon="icon" class="n-tip-icon" />
|
|
5
|
+
</slot>
|
|
6
|
+
<div>
|
|
7
|
+
<slot />
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup lang="ts">
|
|
13
|
+
defineProps<{
|
|
14
|
+
icon?: string
|
|
15
|
+
}>()
|
|
16
|
+
</script>
|
package/dist/nuxt.cjs
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const url = require('url');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const kit = require('@nuxt/kit');
|
|
7
|
+
const UnocssModule = require('@unocss/nuxt');
|
|
8
|
+
const VueUseModule = require('@vueuse/nuxt');
|
|
9
|
+
const core = require('@unocss/core');
|
|
10
|
+
const presetUno = require('@unocss/preset-uno');
|
|
11
|
+
const rules = require('@unocss/preset-mini/rules');
|
|
12
|
+
const presetIcons = require('@unocss/preset-icons');
|
|
13
|
+
const presetAttributify = require('@unocss/preset-attributify');
|
|
14
|
+
|
|
15
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
16
|
+
|
|
17
|
+
const UnocssModule__default = /*#__PURE__*/_interopDefaultLegacy(UnocssModule);
|
|
18
|
+
const VueUseModule__default = /*#__PURE__*/_interopDefaultLegacy(VueUseModule);
|
|
19
|
+
const presetUno__default = /*#__PURE__*/_interopDefaultLegacy(presetUno);
|
|
20
|
+
const presetIcons__default = /*#__PURE__*/_interopDefaultLegacy(presetIcons);
|
|
21
|
+
const presetAttributify__default = /*#__PURE__*/_interopDefaultLegacy(presetAttributify);
|
|
22
|
+
|
|
23
|
+
const NuxtUIPreset = {
|
|
24
|
+
name: "nuxt-ui",
|
|
25
|
+
theme: core.mergeDeep(presetUno.theme, {
|
|
26
|
+
colors: {
|
|
27
|
+
context: "rgba(var(--nui-c-context),%alpha)"
|
|
28
|
+
},
|
|
29
|
+
fontFamily: {
|
|
30
|
+
sans: "Avenir, Helvetica, Arial, sans-serif"
|
|
31
|
+
}
|
|
32
|
+
}),
|
|
33
|
+
rules: [
|
|
34
|
+
[/^n-(.*)$/, ([, body], { theme }) => {
|
|
35
|
+
const { rgba } = rules.parseColorUtil(body, theme) || {};
|
|
36
|
+
if (rgba) {
|
|
37
|
+
return {
|
|
38
|
+
"--nui-c-context": `${rgba.join(",")}`
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}],
|
|
42
|
+
[/^n-(.*)$/, rules.fontSizes[0][1]],
|
|
43
|
+
["n-dashed", { "border-style": "dashed" }],
|
|
44
|
+
["n-solid", {
|
|
45
|
+
"background-color": "rgba(var(--nui-c-context), 1) !important",
|
|
46
|
+
"border-color": "rgba(var(--nui-c-context), 1)",
|
|
47
|
+
"color": "white !important"
|
|
48
|
+
}],
|
|
49
|
+
["n-disabled", {
|
|
50
|
+
"opacity": 0.4,
|
|
51
|
+
"pointer-events": "none",
|
|
52
|
+
"filter": "saturate(0)"
|
|
53
|
+
}]
|
|
54
|
+
],
|
|
55
|
+
variants: [
|
|
56
|
+
(input) => {
|
|
57
|
+
const prefix = "n-disabled:";
|
|
58
|
+
if (input.startsWith(prefix)) {
|
|
59
|
+
return {
|
|
60
|
+
matcher: input.slice(prefix.length),
|
|
61
|
+
selector: (input2) => `[disabled] ${input2}, ${input2}[disabled]`
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
(input) => {
|
|
66
|
+
const prefix = "n-checked:";
|
|
67
|
+
if (input.startsWith(prefix)) {
|
|
68
|
+
return {
|
|
69
|
+
matcher: input.slice(prefix.length),
|
|
70
|
+
selector: (input2) => `[checked] ${input2}, ${input2}[checked]`
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
shortcuts: {
|
|
76
|
+
"n-bg-base": "bg-white dark:bg-[#222]",
|
|
77
|
+
"n-border-base": "border-gray-400/50",
|
|
78
|
+
"n-border-300": "border-gray-400/40",
|
|
79
|
+
"n-border-200": "border-gray-400/25",
|
|
80
|
+
"n-transition": "transition-all duration-200",
|
|
81
|
+
"n-focus-base": "ring-2 ring-context/50",
|
|
82
|
+
"n-active-base": "ring-3 ring-context/10",
|
|
83
|
+
"n-card-base": "border n-border-200 rounded n-bg-base shadow-sm",
|
|
84
|
+
"n-header-upper": "text-sm case-upper mb-2 leading-1.2em tracking-wide op50",
|
|
85
|
+
"n-button-base": "border n-border-base rounded shadow-sm px-1em py-0.25em inline-flex items-center gap-1 op80 !outline-none",
|
|
86
|
+
"n-button-hover": "op100 !border-context text-context",
|
|
87
|
+
"n-button-active": "n-active-base bg-context/5",
|
|
88
|
+
"n-button-icon": "-ml-0.2em mr-0.2em text-1.1em",
|
|
89
|
+
"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",
|
|
90
|
+
"n-checkbox-box-checked": "bg-context border-context",
|
|
91
|
+
"n-checkbox-icon": "carbon-checkmark",
|
|
92
|
+
"n-radio-box": "border n-border-base w-1.2em h-1.2em mr-1 text-white flex flex-none rounded-full overflow-visible",
|
|
93
|
+
"n-radio-box-checked": "border-context",
|
|
94
|
+
"n-radio-inner": "bg-context rounded-1/2 w-0 h-0 m-auto",
|
|
95
|
+
"n-radio-inner-checked": "w-0.8em h-0.8em",
|
|
96
|
+
"n-switch-base": "inline-flex items-center select-none",
|
|
97
|
+
"n-switch-slider": "mr-1 rounded-full border n-border-base relative p-2px",
|
|
98
|
+
"n-switch-slider-checked": "border-context/20 bg-context/10",
|
|
99
|
+
"n-switch-thumb": "h-1em w-1em rounded-1/2 border n-border-base ml-0 mr-0.8em",
|
|
100
|
+
"n-switch-thumb-checked": "bg-context border-context ml-0.8em mr-0",
|
|
101
|
+
"n-tip-base": "bg-context/8 text-context px-1em py-0.4em rounded flex items-center dark:bg-context/12",
|
|
102
|
+
"n-tip-icon": "-ml-0.2em mr-0.4em text-1.1em"
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
function extendUnocssOptions(user = {}) {
|
|
106
|
+
return {
|
|
107
|
+
...user,
|
|
108
|
+
preflight: true,
|
|
109
|
+
presets: [
|
|
110
|
+
presetUno__default(),
|
|
111
|
+
presetAttributify__default(),
|
|
112
|
+
presetIcons__default({
|
|
113
|
+
prefix: "",
|
|
114
|
+
scale: 1.2,
|
|
115
|
+
extraProperties: {
|
|
116
|
+
"display": "inline-block",
|
|
117
|
+
"vertical-align": "middle"
|
|
118
|
+
}
|
|
119
|
+
}),
|
|
120
|
+
NuxtUIPreset,
|
|
121
|
+
...user.presets || []
|
|
122
|
+
]
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const rPath = (p) => url.fileURLToPath(new URL(p, (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('nuxt.cjs', document.baseURI).href))).toString());
|
|
127
|
+
const nuxt = kit.defineNuxtModule({
|
|
128
|
+
name: "nui",
|
|
129
|
+
defaults: {
|
|
130
|
+
preset: rPath("./preset"),
|
|
131
|
+
dev: false
|
|
132
|
+
},
|
|
133
|
+
async setup(options, nuxt) {
|
|
134
|
+
kit.addComponentsDir({ path: rPath("./components") });
|
|
135
|
+
const presetStyles = path.resolve(options.preset, "styles.css");
|
|
136
|
+
if (fs.existsSync(presetStyles))
|
|
137
|
+
nuxt.options.css.push(presetStyles);
|
|
138
|
+
if (!options.dev)
|
|
139
|
+
nuxt.options.unocss = extendUnocssOptions(nuxt.options.unocss);
|
|
140
|
+
await kit.installModule(nuxt, UnocssModule__default);
|
|
141
|
+
await kit.installModule(nuxt, VueUseModule__default);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
module.exports = nuxt;
|
package/dist/nuxt.d.ts
ADDED
package/dist/nuxt.mjs
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { fileURLToPath } from 'url';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
import { existsSync } from 'fs';
|
|
4
|
+
import { defineNuxtModule, addComponentsDir, installModule } from '@nuxt/kit';
|
|
5
|
+
import UnocssModule from '@unocss/nuxt';
|
|
6
|
+
import VueUseModule from '@vueuse/nuxt';
|
|
7
|
+
import { mergeDeep } from '@unocss/core';
|
|
8
|
+
import presetUno, { theme } from '@unocss/preset-uno';
|
|
9
|
+
import { parseColorUtil, fontSizes } from '@unocss/preset-mini/rules';
|
|
10
|
+
import presetIcons from '@unocss/preset-icons';
|
|
11
|
+
import presetAttributify from '@unocss/preset-attributify';
|
|
12
|
+
|
|
13
|
+
const NuxtUIPreset = {
|
|
14
|
+
name: "nuxt-ui",
|
|
15
|
+
theme: mergeDeep(theme, {
|
|
16
|
+
colors: {
|
|
17
|
+
context: "rgba(var(--nui-c-context),%alpha)"
|
|
18
|
+
},
|
|
19
|
+
fontFamily: {
|
|
20
|
+
sans: "Avenir, Helvetica, Arial, sans-serif"
|
|
21
|
+
}
|
|
22
|
+
}),
|
|
23
|
+
rules: [
|
|
24
|
+
[/^n-(.*)$/, ([, body], { theme }) => {
|
|
25
|
+
const { rgba } = parseColorUtil(body, theme) || {};
|
|
26
|
+
if (rgba) {
|
|
27
|
+
return {
|
|
28
|
+
"--nui-c-context": `${rgba.join(",")}`
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}],
|
|
32
|
+
[/^n-(.*)$/, fontSizes[0][1]],
|
|
33
|
+
["n-dashed", { "border-style": "dashed" }],
|
|
34
|
+
["n-solid", {
|
|
35
|
+
"background-color": "rgba(var(--nui-c-context), 1) !important",
|
|
36
|
+
"border-color": "rgba(var(--nui-c-context), 1)",
|
|
37
|
+
"color": "white !important"
|
|
38
|
+
}],
|
|
39
|
+
["n-disabled", {
|
|
40
|
+
"opacity": 0.4,
|
|
41
|
+
"pointer-events": "none",
|
|
42
|
+
"filter": "saturate(0)"
|
|
43
|
+
}]
|
|
44
|
+
],
|
|
45
|
+
variants: [
|
|
46
|
+
(input) => {
|
|
47
|
+
const prefix = "n-disabled:";
|
|
48
|
+
if (input.startsWith(prefix)) {
|
|
49
|
+
return {
|
|
50
|
+
matcher: input.slice(prefix.length),
|
|
51
|
+
selector: (input2) => `[disabled] ${input2}, ${input2}[disabled]`
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
(input) => {
|
|
56
|
+
const prefix = "n-checked:";
|
|
57
|
+
if (input.startsWith(prefix)) {
|
|
58
|
+
return {
|
|
59
|
+
matcher: input.slice(prefix.length),
|
|
60
|
+
selector: (input2) => `[checked] ${input2}, ${input2}[checked]`
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
shortcuts: {
|
|
66
|
+
"n-bg-base": "bg-white dark:bg-[#222]",
|
|
67
|
+
"n-border-base": "border-gray-400/50",
|
|
68
|
+
"n-border-300": "border-gray-400/40",
|
|
69
|
+
"n-border-200": "border-gray-400/25",
|
|
70
|
+
"n-transition": "transition-all duration-200",
|
|
71
|
+
"n-focus-base": "ring-2 ring-context/50",
|
|
72
|
+
"n-active-base": "ring-3 ring-context/10",
|
|
73
|
+
"n-card-base": "border n-border-200 rounded n-bg-base shadow-sm",
|
|
74
|
+
"n-header-upper": "text-sm case-upper mb-2 leading-1.2em tracking-wide op50",
|
|
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",
|
|
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
|
+
"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",
|
|
80
|
+
"n-checkbox-box-checked": "bg-context border-context",
|
|
81
|
+
"n-checkbox-icon": "carbon-checkmark",
|
|
82
|
+
"n-radio-box": "border n-border-base w-1.2em h-1.2em mr-1 text-white flex flex-none rounded-full overflow-visible",
|
|
83
|
+
"n-radio-box-checked": "border-context",
|
|
84
|
+
"n-radio-inner": "bg-context rounded-1/2 w-0 h-0 m-auto",
|
|
85
|
+
"n-radio-inner-checked": "w-0.8em h-0.8em",
|
|
86
|
+
"n-switch-base": "inline-flex items-center select-none",
|
|
87
|
+
"n-switch-slider": "mr-1 rounded-full border n-border-base relative p-2px",
|
|
88
|
+
"n-switch-slider-checked": "border-context/20 bg-context/10",
|
|
89
|
+
"n-switch-thumb": "h-1em w-1em rounded-1/2 border n-border-base ml-0 mr-0.8em",
|
|
90
|
+
"n-switch-thumb-checked": "bg-context border-context ml-0.8em mr-0",
|
|
91
|
+
"n-tip-base": "bg-context/8 text-context px-1em py-0.4em rounded flex items-center dark:bg-context/12",
|
|
92
|
+
"n-tip-icon": "-ml-0.2em mr-0.4em text-1.1em"
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
function extendUnocssOptions(user = {}) {
|
|
96
|
+
return {
|
|
97
|
+
...user,
|
|
98
|
+
preflight: true,
|
|
99
|
+
presets: [
|
|
100
|
+
presetUno(),
|
|
101
|
+
presetAttributify(),
|
|
102
|
+
presetIcons({
|
|
103
|
+
prefix: "",
|
|
104
|
+
scale: 1.2,
|
|
105
|
+
extraProperties: {
|
|
106
|
+
"display": "inline-block",
|
|
107
|
+
"vertical-align": "middle"
|
|
108
|
+
}
|
|
109
|
+
}),
|
|
110
|
+
NuxtUIPreset,
|
|
111
|
+
...user.presets || []
|
|
112
|
+
]
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const rPath = (p) => fileURLToPath(new URL(p, import.meta.url).toString());
|
|
117
|
+
const nuxt = defineNuxtModule({
|
|
118
|
+
name: "nui",
|
|
119
|
+
defaults: {
|
|
120
|
+
preset: rPath("./preset"),
|
|
121
|
+
dev: false
|
|
122
|
+
},
|
|
123
|
+
async setup(options, nuxt) {
|
|
124
|
+
addComponentsDir({ path: rPath("./components") });
|
|
125
|
+
const presetStyles = resolve(options.preset, "styles.css");
|
|
126
|
+
if (existsSync(presetStyles))
|
|
127
|
+
nuxt.options.css.push(presetStyles);
|
|
128
|
+
if (!options.dev)
|
|
129
|
+
nuxt.options.unocss = extendUnocssOptions(nuxt.options.unocss);
|
|
130
|
+
await installModule(nuxt, UnocssModule);
|
|
131
|
+
await installModule(nuxt, VueUseModule);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
export { nuxt as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nuxt/ui",
|
|
3
|
+
"version": "0.0.0-alpha.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "unbuild && cp -R src/components dist/",
|
|
8
|
+
"lint": "eslint . --ext .vue,.ts",
|
|
9
|
+
"dev": "yarn nuxi dev playground"
|
|
10
|
+
},
|
|
11
|
+
"main": "./dist/nuxt.mjs",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/nuxt.mjs",
|
|
15
|
+
"require": "./nuxt.cjs"
|
|
16
|
+
},
|
|
17
|
+
"./nuxt": {
|
|
18
|
+
"import": "./dist/nuxt.mjs",
|
|
19
|
+
"require": "./nuxt.cjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@nuxt/kit": "npm:@nuxt/kit-edge@latest",
|
|
27
|
+
"@unocss/core": "^0.15.6",
|
|
28
|
+
"@unocss/nuxt": "^0.15.6",
|
|
29
|
+
"@unocss/preset-attributify": "^0.15.6",
|
|
30
|
+
"@unocss/preset-icons": "^0.15.6",
|
|
31
|
+
"@unocss/preset-mini": "^0.15.6",
|
|
32
|
+
"@unocss/preset-uno": "^0.15.6",
|
|
33
|
+
"@unocss/reset": "^0.15.6",
|
|
34
|
+
"@vueuse/nuxt": "^7.2.2",
|
|
35
|
+
"@vueuse/integrations": "^7.2.2",
|
|
36
|
+
"focus-trap": "^6.7.1"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@antfu/eslint-config": "^0.12.2",
|
|
40
|
+
"@iconify-json/carbon": "^1.0.12",
|
|
41
|
+
"eslint": "^8.4.1",
|
|
42
|
+
"nuxt3": "latest",
|
|
43
|
+
"typescript": "^4.5.2",
|
|
44
|
+
"unbuild": "^0.6.3"
|
|
45
|
+
},
|
|
46
|
+
"eslintConfig": {
|
|
47
|
+
"extends": "@antfu"
|
|
48
|
+
}
|
|
49
|
+
}
|