@witchcraft/ui 0.2.1-beta.3 → 0.2.2
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/dist/module.json +1 -1
- package/dist/module.mjs +20 -4
- package/dist/runtime/build/WitchcraftUiResolver.d.ts +2 -2
- package/dist/runtime/build/generateTheme.js +2 -2
- package/dist/runtime/components/Aria/Aria.d.vue.ts +5 -0
- package/dist/runtime/components/Aria/Aria.vue +4 -2
- package/dist/runtime/components/Aria/Aria.vue.d.ts +1 -1
- package/dist/runtime/components/Icon/Icon.d.vue.ts +21 -0
- package/dist/runtime/components/Icon/Icon.vue +3 -3
- package/dist/runtime/components/Icon/Icon.vue.d.ts +1 -1
- package/dist/runtime/components/LibButton/LibButton.d.vue.ts +36 -0
- package/dist/runtime/components/LibButton/LibButton.vue +9 -4
- package/dist/runtime/components/LibButton/LibButton.vue.d.ts +1 -1
- package/dist/runtime/components/LibCheckbox/LibCheckbox.d.vue.ts +42 -0
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +3 -4
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +1 -1
- package/dist/runtime/components/LibColorInput/LibColorInput.d.vue.ts +63 -0
- package/dist/runtime/components/LibColorInput/LibColorInput.vue +15 -8
- package/dist/runtime/components/LibColorInput/LibColorInput.vue.d.ts +1 -1
- package/dist/runtime/components/LibColorPicker/LibColorPicker.d.vue.ts +61 -0
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +10 -6
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue.d.ts +1 -1
- package/dist/runtime/components/LibColorPicker/utils/truncate.js +1 -1
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.d.vue.ts +22 -0
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +5 -2
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue.d.ts +1 -1
- package/dist/runtime/components/LibDatePicker/LibDatePicker.d.vue.ts +40 -0
- package/dist/runtime/components/LibDatePicker/LibDatePicker.vue.d.ts +1 -1
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.d.vue.ts +34 -0
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue +8 -6
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue.d.ts +1 -1
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.d.vue.ts +34 -0
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +7 -5
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue.d.ts +1 -1
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.d.vue.ts +22 -0
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue.d.ts +1 -1
- package/dist/runtime/components/LibDebug/LibDebug.d.vue.ts +32 -0
- package/dist/runtime/components/LibDebug/LibDebug.vue +9 -4
- package/dist/runtime/components/LibDebug/LibDebug.vue.d.ts +1 -1
- package/dist/runtime/components/LibDevOnly/LibDevOnly.d.vue.ts +25 -0
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue +2 -1
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue.d.ts +4 -1
- package/dist/runtime/components/LibFileInput/LibFileInput.d.vue.ts +43 -0
- package/dist/runtime/components/LibFileInput/LibFileInput.vue +29 -13
- package/dist/runtime/components/LibFileInput/LibFileInput.vue.d.ts +2 -2
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.d.vue.ts +165 -0
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +42 -12
- package/dist/runtime/components/LibLabel/LibLabel.d.vue.ts +26 -0
- package/dist/runtime/components/LibLabel/LibLabel.vue +2 -2
- package/dist/runtime/components/LibLabel/LibLabel.vue.d.ts +3 -3
- package/dist/runtime/components/LibMultiValues/LibMultiValues.d.vue.ts +29 -0
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +1 -2
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue.d.ts +2 -2
- package/dist/runtime/components/LibNotifications/LibNotification.d.vue.ts +17 -0
- package/dist/runtime/components/LibNotifications/LibNotification.vue +19 -8
- package/dist/runtime/components/LibNotifications/LibNotifications.d.vue.ts +13 -0
- package/dist/runtime/components/LibNotifications/LibNotifications.vue +10 -6
- package/dist/runtime/components/LibNotifications/LibNotifications.vue.d.ts +2 -2
- package/dist/runtime/components/LibPagination/LibPagination.d.vue.ts +104 -0
- package/dist/runtime/components/LibPagination/LibPagination.vue +25 -12
- package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +2 -2
- package/dist/runtime/components/LibPalette/LibPalette.d.vue.ts +14 -0
- package/dist/runtime/components/LibPalette/LibPalette.vue +6 -5
- package/dist/runtime/components/LibPalette/LibPalette.vue.d.ts +5 -5
- package/dist/runtime/components/LibPopup/LibPopup.d.vue.ts +46 -0
- package/dist/runtime/components/LibPopup/LibPopup.vue +6 -4
- package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +3 -3
- package/dist/runtime/components/LibProgressBar/LibProgressBar.d.vue.ts +41 -0
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +5 -3
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue.d.ts +9 -9
- package/dist/runtime/components/LibRecorder/LibRecorder.d.vue.ts +77 -0
- package/dist/runtime/components/LibRecorder/LibRecorder.vue +1 -1
- package/dist/runtime/components/LibRecorder/LibRecorder.vue.d.ts +2 -2
- package/dist/runtime/components/LibRoot/LibRoot.d.vue.ts +41 -0
- package/dist/runtime/components/LibRoot/LibRoot.vue +11 -6
- package/dist/runtime/components/LibRoot/LibRoot.vue.d.ts +1 -1
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.d.vue.ts +35 -0
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue +1 -1
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue.d.ts +1 -1
- package/dist/runtime/components/LibSuggestions/LibSuggestions.d.vue.ts +94 -0
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +6 -4
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +1 -1
- package/dist/runtime/components/LibTable/LibTable.d.vue.ts +45 -0
- package/dist/runtime/components/LibTable/LibTable.vue +23 -8
- package/dist/runtime/components/LibTable/LibTable.vue.d.ts +1 -1
- package/dist/runtime/components/Template/NAME.d.vue.ts +17 -0
- package/dist/runtime/components/Template/NAME.vue +2 -3
- package/dist/runtime/components/Template/NAME.vue.d.ts +1 -1
- package/dist/runtime/components/TestControls/TestControls.d.vue.ts +5 -0
- package/dist/runtime/components/TestControls/TestControls.vue +4 -2
- package/dist/runtime/components/TestControls/TestControls.vue.d.ts +1 -1
- package/dist/runtime/composables/useDragWithThreshold.d.ts +1 -1
- package/dist/runtime/composables/useInjectedI18n.d.ts +1 -1
- package/dist/runtime/composables/useScrollNearContainerEdges.d.ts +1 -1
- package/dist/runtime/composables/useSetupI18n.d.ts +1 -1
- package/dist/runtime/composables/useSuggestions.d.ts +2 -2
- package/dist/runtime/helpers/NotificationHandler.d.ts +1 -1
- package/dist/runtime/helpers/base64ToImg.js +2 -2
- package/dist/runtime/tailwind/themeConvertionOpts.d.ts +1 -1
- package/dist/runtime/types/index.d.ts +1 -1
- package/dist/runtime/utils/notifyIfError.d.ts +1 -1
- package/package.json +9 -10
- package/src/module.ts +41 -33
- package/src/runtime/build/WitchcraftUiResolver.ts +3 -3
- package/src/runtime/build/generateTheme.ts +3 -2
- package/src/runtime/build/unpluginIconViteOptions.ts +1 -1
- package/src/runtime/components/Aria/Aria.vue +5 -6
- package/src/runtime/components/Focus.stories.ts +11 -12
- package/src/runtime/components/Icon/Icon.vue +5 -9
- package/src/runtime/components/LibButton/LibButton.stories.ts +21 -22
- package/src/runtime/components/LibButton/LibButton.vue +23 -21
- package/src/runtime/components/LibCheckbox/LibCheckbox.stories.ts +6 -10
- package/src/runtime/components/LibCheckbox/LibCheckbox.vue +17 -19
- package/src/runtime/components/LibColorInput/LibColorInput.stories.ts +8 -13
- package/src/runtime/components/LibColorInput/LibColorInput.vue +49 -45
- package/src/runtime/components/LibColorPicker/LibColorPicker.stories.ts +14 -18
- package/src/runtime/components/LibColorPicker/LibColorPicker.vue +50 -52
- package/src/runtime/components/LibColorPicker/utils/safeConvertToHsva.ts +1 -2
- package/src/runtime/components/LibColorPicker/utils/safeConvertToRgba.ts +1 -2
- package/src/runtime/components/LibColorPicker/utils/truncate.ts +1 -2
- package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.ts +5 -8
- package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +11 -9
- package/src/runtime/components/LibDatePicker/LibDatePicker.stories.ts +14 -15
- package/src/runtime/components/LibDatePicker/LibDatePicker.vue +1 -2
- package/src/runtime/components/LibDatePicker/LibRangeDatePicker.vue +13 -13
- package/src/runtime/components/LibDatePicker/LibSingleDatePicker.vue +9 -8
- package/src/runtime/components/LibDatePicker/LibTimeZonePicker.vue +2 -1
- package/src/runtime/components/LibDatePicker/helpers.ts +0 -2
- package/src/runtime/components/LibDebug/LibDebug.stories.ts +11 -15
- package/src/runtime/components/LibDebug/LibDebug.vue +14 -11
- package/src/runtime/components/LibDevOnly/LibDevOnly.vue +8 -4
- package/src/runtime/components/LibFileInput/LibFileInput.stories.ts +12 -15
- package/src/runtime/components/LibFileInput/LibFileInput.vue +65 -47
- package/src/runtime/components/LibInputDeprecated/LibInputDeprecated.stories.ts +77 -84
- package/src/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +73 -48
- package/src/runtime/components/LibLabel/LibLabel.stories.ts +4 -8
- package/src/runtime/components/LibLabel/LibLabel.vue +8 -8
- package/src/runtime/components/LibMultiValues/LibMultiValues.stories.ts +10 -15
- package/src/runtime/components/LibMultiValues/LibMultiValues.vue +14 -18
- package/src/runtime/components/LibNotifications/LibNotification.stories.ts +30 -34
- package/src/runtime/components/LibNotifications/LibNotification.vue +27 -17
- package/src/runtime/components/LibNotifications/LibNotifications.stories.ts +11 -15
- package/src/runtime/components/LibNotifications/LibNotifications.vue +21 -16
- package/src/runtime/components/LibPagination/LibPagination.stories.ts +5 -9
- package/src/runtime/components/LibPagination/LibPagination.vue +46 -32
- package/src/runtime/components/LibPalette/LibPalette.stories.ts +3 -7
- package/src/runtime/components/LibPalette/LibPalette.vue +13 -12
- package/src/runtime/components/LibPopup/LibPopup.stories.ts +19 -23
- package/src/runtime/components/LibPopup/LibPopup.vue +31 -35
- package/src/runtime/components/LibProgressBar/LibProgressBar.stories.ts +13 -17
- package/src/runtime/components/LibProgressBar/LibProgressBar.vue +36 -33
- package/src/runtime/components/LibRecorder/LibRecorder.stories.ts +11 -12
- package/src/runtime/components/LibRecorder/LibRecorder.vue +34 -34
- package/src/runtime/components/LibRoot/LibRoot.vue +16 -12
- package/src/runtime/components/LibSimpleInput/LibSimpleInput.stories.ts +20 -24
- package/src/runtime/components/LibSimpleInput/LibSimpleInput.vue +17 -21
- package/src/runtime/components/LibSuggestions/LibSuggestions.stories.ts +16 -19
- package/src/runtime/components/LibSuggestions/LibSuggestions.vue +28 -30
- package/src/runtime/components/LibTable/LibTable.stories.ts +30 -33
- package/src/runtime/components/LibTable/LibTable.vue +38 -24
- package/src/runtime/components/Reset.stories.ts +3 -6
- package/src/runtime/components/Scrolling.stories.ts +5 -8
- package/src/runtime/components/Template/NAME.vue +11 -11
- package/src/runtime/components/Template/TemplateStory.ts +9 -10
- package/src/runtime/components/TestControls/TestControls.vue +5 -5
- package/src/runtime/components/shared/props.ts +4 -6
- package/src/runtime/components/shared/storyHelpers/playInput.ts +2 -3
- package/src/runtime/components/shared/storyHelpers/playSuggestions.ts +5 -9
- package/src/runtime/composables/useAccesibilityOutline.ts +1 -1
- package/src/runtime/composables/useAriaLabel.ts +1 -1
- package/src/runtime/composables/useDarkMode.ts +15 -19
- package/src/runtime/composables/useDragWithThreshold.ts +6 -8
- package/src/runtime/composables/useGlobalResizeObserver.ts +0 -1
- package/src/runtime/composables/useInjectedDarkMode.ts +2 -2
- package/src/runtime/composables/useInjectedI18n.ts +1 -1
- package/src/runtime/composables/useInjectedLocale.ts +3 -4
- package/src/runtime/composables/useScrollNearContainerEdges.stories.ts +4 -4
- package/src/runtime/composables/useScrollNearContainerEdges.ts +12 -13
- package/src/runtime/composables/useSetupI18n.ts +4 -7
- package/src/runtime/composables/useSetupLocale.ts +3 -5
- package/src/runtime/composables/useSuggestions.ts +25 -30
- package/src/runtime/directives/vDetectFlex.ts +5 -8
- package/src/runtime/directives/vExtractRootEl.ts +1 -1
- package/src/runtime/directives/vResizableCols.ts +3 -7
- package/src/runtime/directives/vResizeObserver.ts +1 -2
- package/src/runtime/globalResizeObserver.ts +0 -1
- package/src/runtime/helpers/NotificationHandler.ts +8 -12
- package/src/runtime/helpers/base64ToImg.ts +2 -3
- package/src/runtime/helpers/createNoonUtcDate.ts +0 -1
- package/src/runtime/helpers/defaultTranslationFunction.ts +0 -1
- package/src/runtime/helpers/getTimeZoneList.ts +0 -1
- package/src/runtime/helpers/readFile.ts +2 -2
- package/src/runtime/helpers/resizeObserverWrapper.ts +0 -1
- package/src/runtime/helpers/storybook.ts +2 -3
- package/src/runtime/main.lib.ts +0 -2
- package/src/runtime/nuxt/plugins/vue-plugin.ts +4 -5
- package/src/runtime/tailwind/themeConvertionOpts.ts +3 -4
- package/src/runtime/theme.ts +0 -1
- package/src/runtime/types/index.ts +3 -4
- package/src/runtime/utils/notifyIfError.ts +2 -2
- package/src/runtime/utils/twMerge.ts +2 -2
- package/src/runtime/vue/VueComponentsPlugin.ts +1 -2
- package/src/runtime/vue/registerComponents.ts +0 -1
package/src/module.ts
CHANGED
|
@@ -4,21 +4,23 @@ import {
|
|
|
4
4
|
addImports, addTemplate, addTypeTemplate,
|
|
5
5
|
createResolver,
|
|
6
6
|
defineNuxtModule,
|
|
7
|
-
|
|
8
|
-
useLogger,
|
|
7
|
+
useLogger
|
|
9
8
|
} from "@nuxt/kit"
|
|
10
9
|
import tailwindcss from "@tailwindcss/vite"
|
|
11
10
|
import { addImportsCustom } from "@witchcraft/nuxt-utils/utils/addImportsCustom"
|
|
12
11
|
import { globFiles } from "@witchcraft/nuxt-utils/utils/globFiles"
|
|
13
12
|
import { defu } from "defu"
|
|
14
|
-
import fs from "fs"
|
|
15
13
|
import { themeAsTailwindCss } from "metamorphosis/tailwind"
|
|
14
|
+
import fs from "node:fs"
|
|
16
15
|
import IconsResolver from "unplugin-icons/resolver"
|
|
17
16
|
import ViteComponents from "unplugin-vue-components/vite"
|
|
18
17
|
|
|
19
18
|
import { unpluginIconViteOptions } from "./runtime/build/unpluginIconViteOptions.js"
|
|
20
19
|
import { themeConvertionOpts } from "./runtime/tailwind/themeConvertionOpts.js"
|
|
21
20
|
import { theme } from "./runtime/theme.js"
|
|
21
|
+
|
|
22
|
+
import pkg from "../package.json" assert { type: "json" }
|
|
23
|
+
|
|
22
24
|
const knownDirectives = ["vExtractRootEl", "vResizableCols", "vResizeObserver", "vResizableCols"] as const
|
|
23
25
|
|
|
24
26
|
const { resolve, resolvePath } = createResolver(import.meta.url)
|
|
@@ -29,11 +31,11 @@ const componentsInfo: {
|
|
|
29
31
|
filepath: string
|
|
30
32
|
}[] = globFiles([
|
|
31
33
|
`${resolve("./runtime/components")}/**/*.vue*`,
|
|
32
|
-
`!**/Template/**.vue
|
|
33
|
-
],[], (filepath: string, name: string) => ({
|
|
34
|
+
`!**/Template/**.vue`
|
|
35
|
+
], [], (filepath: string, name: string) => ({
|
|
34
36
|
originalName: name,
|
|
35
37
|
name: name.startsWith("Lib") ? name.replace("Lib", "PREFIX") : `PREFIX${name}`,
|
|
36
|
-
filepath
|
|
38
|
+
filepath
|
|
37
39
|
}))
|
|
38
40
|
|
|
39
41
|
declare module "@nuxt/schema" {
|
|
@@ -42,7 +44,6 @@ declare module "@nuxt/schema" {
|
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
|
|
46
47
|
export interface ModuleOptions {
|
|
47
48
|
/**
|
|
48
49
|
* Whether to include the vite unplugin-icons plugins (pre-configured with the ui module's defaults.
|
|
@@ -71,18 +72,27 @@ export interface ModuleOptions {
|
|
|
71
72
|
export default defineNuxtModule<ModuleOptions>({
|
|
72
73
|
meta: {
|
|
73
74
|
name: "witchcraftUi",
|
|
74
|
-
configKey: "witchcraftUi"
|
|
75
|
+
configKey: "witchcraftUi"
|
|
75
76
|
},
|
|
76
77
|
defaults: {
|
|
77
78
|
includeUnpluginIconsPlugins: true,
|
|
78
|
-
directives: [
|
|
79
|
+
directives: [...knownDirectives],
|
|
79
80
|
globalComponents: [
|
|
80
|
-
...componentsInfo.map(_ => _.name.slice("PREFIX".length))
|
|
81
|
+
...componentsInfo.map(_ => _.name.slice("PREFIX".length))
|
|
81
82
|
],
|
|
82
83
|
componentPrefix: "W",
|
|
83
84
|
debug: true,
|
|
84
85
|
mainCssFile: "~/assets/css/tailwind.css",
|
|
85
|
-
_playgroundWorkaround: false
|
|
86
|
+
_playgroundWorkaround: false
|
|
87
|
+
},
|
|
88
|
+
moduleDependencies: {
|
|
89
|
+
"unplugin-icons/nuxt": {
|
|
90
|
+
version: pkg.dependencies["unplugin-icons"],
|
|
91
|
+
defaults: unpluginIconViteOptions as any
|
|
92
|
+
},
|
|
93
|
+
"reka-ui/nuxt": {
|
|
94
|
+
version: pkg.dependencies["reka-ui"]
|
|
95
|
+
}
|
|
86
96
|
},
|
|
87
97
|
async setup(options, nuxt) {
|
|
88
98
|
const moduleName = "@witchcraft/ui"
|
|
@@ -97,7 +107,6 @@ export default defineNuxtModule<ModuleOptions>({
|
|
|
97
107
|
}
|
|
98
108
|
}
|
|
99
109
|
|
|
100
|
-
|
|
101
110
|
const unknownDirectives = options.directives.filter(_ => !knownDirectives.includes(_))
|
|
102
111
|
if (unknownDirectives.length > 0) {
|
|
103
112
|
throw new Error(`Witchcraft Components: Directives list contains unknown directives: ${unknownDirectives.join(",")}`)
|
|
@@ -105,11 +114,10 @@ export default defineNuxtModule<ModuleOptions>({
|
|
|
105
114
|
nuxt.options.runtimeConfig.public.witchcraftUi = defu(
|
|
106
115
|
nuxt.options.runtimeConfig.public.witchcraftUi,
|
|
107
116
|
{
|
|
108
|
-
directives: options.directives
|
|
117
|
+
directives: options.directives
|
|
109
118
|
}
|
|
110
119
|
)
|
|
111
120
|
|
|
112
|
-
|
|
113
121
|
addTemplate({
|
|
114
122
|
filename: "witchcraft-ui.css",
|
|
115
123
|
write: true,
|
|
@@ -127,13 +135,12 @@ export default defineNuxtModule<ModuleOptions>({
|
|
|
127
135
|
${indent(filteredComponentsInfo.map(_ => `@source "${_.filepath}";`).join("\n"), 5)}
|
|
128
136
|
`
|
|
129
137
|
})
|
|
130
|
-
|
|
131
|
-
|
|
138
|
+
|
|
132
139
|
await Promise.all(filteredComponentsInfo
|
|
133
140
|
.map(async entry => addComponent({
|
|
134
141
|
filePath: entry.filepath,
|
|
135
142
|
name: entry.name,
|
|
136
|
-
global: options.globalComponents.includes(entry.name.slice(options.componentPrefix.length))
|
|
143
|
+
global: options.globalComponents.includes(entry.name.slice(options.componentPrefix.length))
|
|
137
144
|
}))
|
|
138
145
|
)
|
|
139
146
|
|
|
@@ -142,12 +149,12 @@ export default defineNuxtModule<ModuleOptions>({
|
|
|
142
149
|
const added: string[] = []
|
|
143
150
|
addImportsCustom([
|
|
144
151
|
`${resolve("runtime/composables")}/**/*`,
|
|
145
|
-
`${resolve("runtime/utils")}
|
|
146
|
-
], [],(filePath: string, name: string) => {
|
|
152
|
+
`${resolve("runtime/utils")}/**/*`
|
|
153
|
+
], [], (filePath: string, name: string) => {
|
|
147
154
|
added.push(name)
|
|
148
155
|
return addImports({
|
|
149
156
|
name,
|
|
150
|
-
from: filePath
|
|
157
|
+
from: filePath
|
|
151
158
|
})
|
|
152
159
|
})
|
|
153
160
|
logger.info(`Added imports: ${added.join(", ")}`)
|
|
@@ -161,26 +168,31 @@ export default defineNuxtModule<ModuleOptions>({
|
|
|
161
168
|
options.includeUnpluginIconsPlugins
|
|
162
169
|
? [
|
|
163
170
|
// we must prepend or the custom style options don't work when the module is used
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
171
|
+
ViteComponents({
|
|
172
|
+
resolvers: [
|
|
173
|
+
IconsResolver({ prefix: "i" })
|
|
174
|
+
]
|
|
175
|
+
})
|
|
169
176
|
// Icons({
|
|
170
177
|
// compiler: "vue3",
|
|
171
178
|
// ...unpluginIconViteOptions,
|
|
172
179
|
// }),
|
|
173
|
-
|
|
180
|
+
]
|
|
174
181
|
: []
|
|
175
182
|
),
|
|
176
183
|
tailwindcss() as any,
|
|
177
|
-
...config.plugins
|
|
184
|
+
...config.plugins
|
|
178
185
|
]
|
|
179
186
|
config.optimizeDeps ??= {}
|
|
180
187
|
config.optimizeDeps.exclude ??= []
|
|
181
188
|
config.optimizeDeps.exclude.push("~icons")
|
|
182
189
|
}
|
|
183
190
|
})
|
|
191
|
+
|
|
192
|
+
nuxt.options.typescript.tsConfig.compilerOptions ??= {}
|
|
193
|
+
nuxt.options.typescript.tsConfig.compilerOptions.types ??= []
|
|
194
|
+
nuxt.options.typescript.tsConfig.compilerOptions.types.push("unplugin-icons/types/vue3")
|
|
195
|
+
|
|
184
196
|
const mainCssFile = await resolvePath(options.mainCssFile!, nuxt.options.alias)
|
|
185
197
|
|
|
186
198
|
const exists = fs.existsSync(mainCssFile)
|
|
@@ -188,17 +200,13 @@ export default defineNuxtModule<ModuleOptions>({
|
|
|
188
200
|
nuxt.options.css.push(mainCssFile)
|
|
189
201
|
}
|
|
190
202
|
|
|
191
|
-
// we need to hook in first before it does, otherwise the plugins don't load correctly
|
|
192
|
-
await installModule("unplugin-icons/nuxt", unpluginIconViteOptions)
|
|
193
|
-
await installModule("reka-ui/nuxt")
|
|
194
|
-
|
|
195
203
|
// todo make names more specific
|
|
196
204
|
// addImportsDir(resolve("helpers"))
|
|
197
205
|
nuxt.options.alias["#witchcraft-ui"] = resolve("runtime")
|
|
198
206
|
nuxt.options.alias["#witchcraft-ui-helpers"] = resolve("runtime/helpers")
|
|
199
207
|
addTypeTemplate({
|
|
200
208
|
filename: "types/witchcraft-ui.d.ts",
|
|
201
|
-
getContents: () => fs.readFileSync(resolve("../types/global.d.ts")).toString()
|
|
209
|
+
getContents: () => fs.readFileSync(resolve("../types/global.d.ts")).toString()
|
|
202
210
|
})
|
|
203
|
-
}
|
|
211
|
+
}
|
|
204
212
|
})
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ComponentResolver } from "unplugin-vue-components"
|
|
2
2
|
|
|
3
3
|
const prefixless = ["Icon", "Aria"]
|
|
4
4
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
5
5
|
export const WitchcraftUiResolver = (
|
|
6
6
|
{
|
|
7
7
|
prefix = "W",
|
|
8
|
-
filter = () => true
|
|
8
|
+
filter = () => true
|
|
9
9
|
}: {
|
|
10
10
|
prefix?: string
|
|
11
11
|
filter?: (name: string) => boolean
|
|
12
12
|
} = {}
|
|
13
13
|
): ComponentResolver => (
|
|
14
|
-
componentName: string
|
|
14
|
+
componentName: string
|
|
15
15
|
): { from: string } | undefined => {
|
|
16
16
|
if (componentName.startsWith(prefix)) {
|
|
17
17
|
const n = componentName.slice(1)
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { themeAsTailwindCss } from "metamorphosis/tailwind"
|
|
2
2
|
import fs from "node:fs"
|
|
3
|
-
import { resolve } from "path"
|
|
3
|
+
import { resolve } from "node:path"
|
|
4
4
|
|
|
5
5
|
import { themeConvertionOpts } from "../tailwind/themeConvertionOpts.js"
|
|
6
6
|
import { theme } from "../theme.js"
|
|
7
|
+
|
|
7
8
|
const css = themeAsTailwindCss(theme, themeConvertionOpts)
|
|
8
|
-
import url from "url"
|
|
9
|
+
import url from "node:url"
|
|
9
10
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
10
11
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url))
|
|
11
12
|
const filepath = resolve(__dirname, "../assets/theme.css")
|
|
@@ -7,5 +7,5 @@ export const unpluginIconViteOptions: Parameters<typeof Icons>[0] = {
|
|
|
7
7
|
},
|
|
8
8
|
// note that we can't use tailwind classes
|
|
9
9
|
// i mean we could, but we have to tell it to include them manually (pain)
|
|
10
|
-
defaultStyle: "vertical-align: -0.125em; height: 1em; display: inline-block; width:auto;"
|
|
10
|
+
defaultStyle: "vertical-align: -0.125em; height: 1em; display: inline-block; width:auto;"
|
|
11
11
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div tabindex="0">
|
|
2
|
+
<div tabindex="0">
|
|
3
|
+
{{ value }}
|
|
4
|
+
</div>
|
|
3
5
|
</template>
|
|
4
6
|
|
|
5
7
|
<script setup lang="ts">
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
defineOptions({ name: "aria" })
|
|
8
|
+
defineOptions({ name: "Aria" })
|
|
10
9
|
defineProps<{
|
|
11
|
-
|
|
10
|
+
|
|
12
11
|
value: string
|
|
13
12
|
}>()
|
|
14
13
|
</script>
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import type { Meta, StoryObj } from "@storybook/vue3"
|
|
3
3
|
import { onMounted, ref } from "vue"
|
|
4
4
|
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
6
5
|
import * as components from "./index.js"
|
|
7
6
|
// TODO move docs to composable
|
|
8
7
|
/**
|
|
@@ -11,8 +10,8 @@ import * as components from "./index.js"
|
|
|
11
10
|
const meta: Meta = {
|
|
12
11
|
title: "Other/Focus",
|
|
13
12
|
args: {
|
|
14
|
-
outline: true
|
|
15
|
-
}
|
|
13
|
+
outline: true
|
|
14
|
+
}
|
|
16
15
|
}
|
|
17
16
|
const template = `
|
|
18
17
|
<div class="focus-outline-no-offset border border-accent-600" tabindex="0">focus-outline-no-offset (outlined i.e. outlined-focus-visible)</div>
|
|
@@ -37,32 +36,32 @@ export const Primary: Story = {
|
|
|
37
36
|
})
|
|
38
37
|
return { ...args, el }
|
|
39
38
|
},
|
|
40
|
-
template
|
|
41
|
-
})
|
|
39
|
+
template
|
|
40
|
+
})
|
|
42
41
|
}
|
|
43
42
|
/* As in force allow, not force show. */
|
|
44
43
|
export const OutlineForcedTrue: Story = {
|
|
45
44
|
...Primary,
|
|
46
45
|
args: {
|
|
47
46
|
...Primary.args,
|
|
48
|
-
forceOutline: true
|
|
49
|
-
}
|
|
47
|
+
forceOutline: true
|
|
48
|
+
}
|
|
50
49
|
}
|
|
51
50
|
export const OutlineFalse: Story = {
|
|
52
51
|
...Primary,
|
|
53
52
|
args: {
|
|
54
53
|
...Primary.args,
|
|
55
|
-
outline: false
|
|
56
|
-
}
|
|
54
|
+
outline: false
|
|
55
|
+
}
|
|
57
56
|
}
|
|
58
|
-
/* We can also allow focus-visible outlines regardless of the state of outline, by wrapping in `.group.outlined-visible`. This is the default for the test wrapper
|
|
57
|
+
/* We can also allow focus-visible outlines regardless of the state of outline, by wrapping in `.group.outlined-visible`. This is the default for the test wrapper. */
|
|
59
58
|
export const AlwaysAllowFocusVisible: Story = {
|
|
60
59
|
render: args => ({
|
|
61
60
|
components,
|
|
62
61
|
setup: () => args,
|
|
63
62
|
template: `
|
|
64
63
|
<div class="outlined-visible group">${template}</div>
|
|
65
|
-
|
|
64
|
+
`
|
|
66
65
|
|
|
67
|
-
})
|
|
66
|
+
})
|
|
68
67
|
}
|
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
3
|
:class="twMerge('icon inline-block', $attrs?.class)"
|
|
4
|
-
v-bind="{...$attrs, class:undefined}"
|
|
4
|
+
v-bind="{ ...$attrs, class: undefined }"
|
|
5
5
|
>
|
|
6
6
|
<slot/>
|
|
7
7
|
</div>
|
|
8
8
|
</template>
|
|
9
9
|
|
|
10
10
|
<script setup lang="ts">
|
|
11
|
-
import {
|
|
11
|
+
import { type HTMLAttributes, useAttrs } from "vue"
|
|
12
12
|
|
|
13
13
|
import { twMerge } from "../../utils/twMerge.js"
|
|
14
14
|
|
|
15
15
|
defineOptions({
|
|
16
|
-
name: "
|
|
17
|
-
inheritAttrs: false
|
|
16
|
+
name: "Icon",
|
|
17
|
+
inheritAttrs: false
|
|
18
18
|
})
|
|
19
19
|
|
|
20
|
-
|
|
21
20
|
const $attrs = useAttrs() as any
|
|
22
21
|
|
|
23
|
-
const props =
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
/* const props = */defineProps<Props>()
|
|
26
23
|
</script>
|
|
27
24
|
|
|
28
25
|
<script lang="ts">
|
|
@@ -40,4 +37,3 @@ interface Props
|
|
|
40
37
|
Partial<Omit<HTMLAttributes, "class">
|
|
41
38
|
> { }
|
|
42
39
|
</script>
|
|
43
|
-
|
|
@@ -4,29 +4,26 @@ import type { Meta, StoryObj } from "@storybook/vue3"
|
|
|
4
4
|
|
|
5
5
|
import IconFaSolidBell from "~icons/fa-solid/bell"
|
|
6
6
|
|
|
7
|
-
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
8
7
|
import * as components from "../index.js"
|
|
9
8
|
|
|
10
|
-
|
|
11
9
|
const meta: Meta<typeof components.LibButton> = {
|
|
12
10
|
component: components.LibButton,
|
|
13
11
|
title: "Components/Button",
|
|
14
12
|
args: {
|
|
15
13
|
label: "Label",
|
|
16
14
|
// @ts-expect-error - custom prop for story
|
|
17
|
-
_iconAfter: true
|
|
18
|
-
}
|
|
15
|
+
_iconAfter: true
|
|
16
|
+
}
|
|
19
17
|
}
|
|
20
18
|
|
|
21
19
|
export default meta
|
|
22
20
|
type Story = StoryObj<typeof components.LibButton>
|
|
23
21
|
|
|
24
|
-
|
|
25
22
|
export const Primary: Story = {
|
|
26
23
|
render: (args: any) => ({
|
|
27
24
|
components: {
|
|
28
25
|
...components,
|
|
29
|
-
IconFaSolidBell
|
|
26
|
+
IconFaSolidBell
|
|
30
27
|
},
|
|
31
28
|
setup: () => ({ args, capitalize }),
|
|
32
29
|
template: `
|
|
@@ -42,16 +39,18 @@ export const Primary: Story = {
|
|
|
42
39
|
<div class="flex flex-col gap-4 pt-10">
|
|
43
40
|
<template v-for="type of [false, 'ok', 'warning', 'danger', 'primary', 'secondary']">
|
|
44
41
|
<lib-button v-bind="{...args, color: type , label: !args.label ? undefined : args.label + ' ' + capitalize(type || 'false') }">
|
|
45
|
-
${args._iconAfter
|
|
42
|
+
${args._iconAfter
|
|
43
|
+
? `
|
|
46
44
|
<template #icon-after>
|
|
47
45
|
<icon class="w-[1em]"><icon-fa-solid-bell /></icon>
|
|
48
46
|
</template>
|
|
49
|
-
`
|
|
47
|
+
`
|
|
48
|
+
: ``}
|
|
50
49
|
</lib-button>
|
|
51
50
|
</template>
|
|
52
51
|
</div>
|
|
53
|
-
|
|
54
|
-
})
|
|
52
|
+
`
|
|
53
|
+
})
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
export const IconAfter: Story = {
|
|
@@ -59,38 +58,38 @@ export const IconAfter: Story = {
|
|
|
59
58
|
args: {
|
|
60
59
|
...Primary.args,
|
|
61
60
|
// @ts-expect-error - .
|
|
62
|
-
_iconAfter: true
|
|
63
|
-
}
|
|
61
|
+
_iconAfter: true
|
|
62
|
+
}
|
|
64
63
|
}
|
|
65
64
|
|
|
66
65
|
export const OnlyIcon: Story = {
|
|
67
66
|
...Primary,
|
|
68
67
|
args: {
|
|
69
68
|
...Primary.args,
|
|
70
|
-
label: undefined
|
|
71
|
-
}
|
|
69
|
+
label: undefined
|
|
70
|
+
}
|
|
72
71
|
}
|
|
73
72
|
export const Disabled: Story = {
|
|
74
73
|
...Primary,
|
|
75
74
|
args: {
|
|
76
75
|
...Primary.args,
|
|
77
|
-
disabled: true
|
|
78
|
-
}
|
|
76
|
+
disabled: true
|
|
77
|
+
}
|
|
79
78
|
}
|
|
80
79
|
export const Borderless: Story = {
|
|
81
80
|
...Primary,
|
|
82
81
|
args: {
|
|
83
82
|
...Primary.args,
|
|
84
|
-
border: false
|
|
85
|
-
}
|
|
83
|
+
border: false
|
|
84
|
+
}
|
|
86
85
|
}
|
|
87
86
|
export const BorderlessDisabled: Story = {
|
|
88
87
|
...Primary,
|
|
89
88
|
args: {
|
|
90
89
|
...Primary.args,
|
|
91
90
|
border: false,
|
|
92
|
-
disabled: true
|
|
93
|
-
}
|
|
91
|
+
disabled: true
|
|
92
|
+
}
|
|
94
93
|
}
|
|
95
94
|
export const WithDivInside: Story = {
|
|
96
95
|
render: (args: any) => ({
|
|
@@ -102,6 +101,6 @@ export const WithDivInside: Story = {
|
|
|
102
101
|
<div>Div inside button still has a pointer cursor.</div>
|
|
103
102
|
</lib-button>
|
|
104
103
|
</div>
|
|
105
|
-
|
|
106
|
-
})
|
|
104
|
+
`
|
|
105
|
+
})
|
|
107
106
|
}
|
|
@@ -55,12 +55,11 @@
|
|
|
55
55
|
dark:hover:shadow-accent-950/30
|
|
56
56
|
dark:active:shadow-fg/40
|
|
57
57
|
dark:active:border-neutral-900
|
|
58
|
-
dark:bg-neutral-800
|
|
59
58
|
dark:border-neutral-900
|
|
60
59
|
dark:disabled:border-neutral-800
|
|
61
60
|
dark:disabled:bg-neutral-900
|
|
62
61
|
`,
|
|
63
|
-
border && (
|
|
62
|
+
border && (!color || color === `secondary`) && `
|
|
64
63
|
after:shadow-bg/90
|
|
65
64
|
hover:after:shadow-bg
|
|
66
65
|
dark:after:shadow-bg/20
|
|
@@ -164,14 +163,20 @@
|
|
|
164
163
|
...autoTitle,
|
|
165
164
|
...$attrs,
|
|
166
165
|
class: undefined,
|
|
167
|
-
...ariaLabel
|
|
166
|
+
...ariaLabel
|
|
168
167
|
}"
|
|
169
168
|
>
|
|
170
|
-
<slot
|
|
171
|
-
|
|
169
|
+
<slot
|
|
170
|
+
name="label"
|
|
171
|
+
v-bind="{ id: `label-${id ?? fallbackId}`, classes: 'button--label pointer-events-none flex flex-1 items-center justify-center gap-1' }"
|
|
172
|
+
>
|
|
173
|
+
<label
|
|
174
|
+
:id="`label-${id ?? fallbackId}`"
|
|
175
|
+
class="button--label pointer-events-none flex flex-1 items-center justify-center gap-1"
|
|
176
|
+
>
|
|
172
177
|
<slot name="icon"/>
|
|
173
178
|
<slot
|
|
174
|
-
v-bind="{ label}"
|
|
179
|
+
v-bind="{ label }"
|
|
175
180
|
>
|
|
176
181
|
<span v-if="label && !isBlank(label!)">
|
|
177
182
|
{{ label }}
|
|
@@ -185,18 +190,16 @@
|
|
|
185
190
|
|
|
186
191
|
<script setup lang="ts">
|
|
187
192
|
import { isBlank } from "@alanscodelog/utils/isBlank"
|
|
188
|
-
import { type ButtonHTMLAttributes,computed, useAttrs } from "vue"
|
|
193
|
+
import { type ButtonHTMLAttributes, computed, useAttrs } from "vue"
|
|
189
194
|
|
|
190
195
|
import { useAriaLabel } from "../../composables/useAriaLabel.js"
|
|
191
196
|
import { twMerge } from "../../utils/twMerge.js"
|
|
192
|
-
import { type BaseInteractiveProps, type ButtonProps,getFallbackId, type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js"
|
|
193
|
-
|
|
197
|
+
import { type BaseInteractiveProps, type ButtonProps, getFallbackId, type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js"
|
|
194
198
|
|
|
195
199
|
const $attrs = useAttrs()
|
|
196
200
|
|
|
197
|
-
|
|
198
201
|
defineOptions({
|
|
199
|
-
name: "
|
|
202
|
+
name: "LibButton"
|
|
200
203
|
})
|
|
201
204
|
|
|
202
205
|
const fallbackId = getFallbackId()
|
|
@@ -204,33 +207,32 @@ const fallbackId = getFallbackId()
|
|
|
204
207
|
const props = withDefaults(defineProps<Props>(), {
|
|
205
208
|
color: false,
|
|
206
209
|
label: "",
|
|
207
|
-
unstyle: false, disabled: false, readonly: false, border: true
|
|
210
|
+
unstyle: false, disabled: false, readonly: false, border: true
|
|
208
211
|
})
|
|
209
212
|
|
|
210
|
-
|
|
211
213
|
const ariaLabel = useAriaLabel(props, fallbackId)
|
|
212
214
|
const autoTitle = computed(() => ({
|
|
213
215
|
title: props.autoTitleFromAria
|
|
214
216
|
? ($attrs["aria-label"] ?? props.label) as string
|
|
215
|
-
: undefined
|
|
217
|
+
: undefined
|
|
216
218
|
}))
|
|
217
|
-
|
|
218
219
|
</script>
|
|
219
220
|
|
|
220
221
|
<script lang="ts">
|
|
221
|
-
type RealProps
|
|
222
|
-
& LinkableByIdProps
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
222
|
+
type RealProps
|
|
223
|
+
= & LinkableByIdProps
|
|
224
|
+
& LabelProps
|
|
225
|
+
& BaseInteractiveProps
|
|
226
|
+
& ButtonProps
|
|
226
227
|
|
|
227
228
|
interface Props
|
|
228
229
|
extends
|
|
229
230
|
/** @vue-ignore */
|
|
230
|
-
Partial<Omit<ButtonHTMLAttributes,"class" | "color" | "disabled">
|
|
231
|
+
Partial<Omit<ButtonHTMLAttributes, "class" | "color" | "disabled">
|
|
231
232
|
& TailwindClassProp
|
|
232
233
|
& {
|
|
233
234
|
// why is this not already a part of button?
|
|
235
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
234
236
|
"aria-label": string
|
|
235
237
|
}>,
|
|
236
238
|
RealProps {}
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
2
|
import type { Meta, StoryObj } from "@storybook/vue3"
|
|
3
3
|
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
5
4
|
import * as components from "../index.js"
|
|
6
5
|
|
|
7
|
-
|
|
8
6
|
const meta = {
|
|
9
7
|
component: components.LibCheckbox,
|
|
10
8
|
title: "Components/Checkbox",
|
|
11
9
|
args: {
|
|
12
10
|
modelValue: true,
|
|
13
|
-
label: "Label"
|
|
14
|
-
}
|
|
11
|
+
label: "Label"
|
|
12
|
+
}
|
|
15
13
|
} satisfies Meta<typeof components.LibCheckbox> & Meta<{ custom: string }>
|
|
16
14
|
|
|
17
15
|
export default meta
|
|
18
16
|
type Story = StoryObj<typeof components.LibCheckbox> // & StoryObj<typeof extraArgs>
|
|
19
17
|
|
|
20
|
-
|
|
21
18
|
export const Primary: Story = {
|
|
22
19
|
render: args => ({
|
|
23
20
|
components,
|
|
@@ -28,14 +25,13 @@ export const Primary: Story = {
|
|
|
28
25
|
Opposite State:
|
|
29
26
|
<br>
|
|
30
27
|
<lib-checkbox v-bind="args" :modelValue="!args.modelValue" @update:modelValue="args.modelValue = !$event"></lib-checkbox>
|
|
31
|
-
|
|
32
|
-
})
|
|
28
|
+
`
|
|
29
|
+
})
|
|
33
30
|
}
|
|
34
31
|
|
|
35
|
-
|
|
36
32
|
export const Disabled = {
|
|
37
33
|
...Primary,
|
|
38
34
|
args: {
|
|
39
|
-
disabled: true
|
|
40
|
-
}
|
|
35
|
+
disabled: true
|
|
36
|
+
}
|
|
41
37
|
}
|