@witchcraft/ui 0.2.1-beta.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.json +1 -1
- package/dist/module.mjs +4 -5
- package/dist/runtime/build/WitchcraftUiResolver.d.ts +2 -2
- package/dist/runtime/build/generateTheme.js +2 -2
- 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.vue +3 -3
- package/dist/runtime/components/Icon/Icon.vue.d.ts +1 -1
- 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.vue +3 -4
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +1 -1
- 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.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.vue +5 -2
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue.d.ts +1 -1
- package/dist/runtime/components/LibDatePicker/LibDatePicker.vue.d.ts +1 -1
- 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.vue +7 -5
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue.d.ts +1 -1
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue.d.ts +1 -1
- 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.vue +2 -1
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue.d.ts +4 -1
- 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.vue +42 -12
- 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.vue +1 -2
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue.d.ts +2 -2
- package/dist/runtime/components/LibNotifications/LibNotification.vue +19 -8
- 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.vue +25 -12
- package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +2 -2
- 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.vue +6 -4
- package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +3 -3
- 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.vue +1 -1
- package/dist/runtime/components/LibRecorder/LibRecorder.vue.d.ts +2 -2
- 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.vue +1 -1
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue.d.ts +1 -1
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +5 -3
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +1 -1
- 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.vue +2 -3
- package/dist/runtime/components/Template/NAME.vue.d.ts +1 -1
- 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 +4 -6
- package/src/module.ts +28 -32
- 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 +59 -67
- 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 +27 -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
|
@@ -5,20 +5,21 @@ import {
|
|
|
5
5
|
createResolver,
|
|
6
6
|
defineNuxtModule,
|
|
7
7
|
installModule,
|
|
8
|
-
useLogger
|
|
8
|
+
useLogger
|
|
9
9
|
} from "@nuxt/kit"
|
|
10
10
|
import tailwindcss from "@tailwindcss/vite"
|
|
11
11
|
import { addImportsCustom } from "@witchcraft/nuxt-utils/utils/addImportsCustom"
|
|
12
12
|
import { globFiles } from "@witchcraft/nuxt-utils/utils/globFiles"
|
|
13
13
|
import { defu } from "defu"
|
|
14
|
-
import fs from "fs"
|
|
15
14
|
import { themeAsTailwindCss } from "metamorphosis/tailwind"
|
|
15
|
+
import fs from "node:fs"
|
|
16
16
|
import IconsResolver from "unplugin-icons/resolver"
|
|
17
17
|
import ViteComponents from "unplugin-vue-components/vite"
|
|
18
18
|
|
|
19
19
|
import { unpluginIconViteOptions } from "./runtime/build/unpluginIconViteOptions.js"
|
|
20
20
|
import { themeConvertionOpts } from "./runtime/tailwind/themeConvertionOpts.js"
|
|
21
21
|
import { theme } from "./runtime/theme.js"
|
|
22
|
+
|
|
22
23
|
const knownDirectives = ["vExtractRootEl", "vResizableCols", "vResizeObserver", "vResizableCols"] as const
|
|
23
24
|
|
|
24
25
|
const { resolve, resolvePath } = createResolver(import.meta.url)
|
|
@@ -29,11 +30,11 @@ const componentsInfo: {
|
|
|
29
30
|
filepath: string
|
|
30
31
|
}[] = globFiles([
|
|
31
32
|
`${resolve("./runtime/components")}/**/*.vue*`,
|
|
32
|
-
`!**/Template/**.vue
|
|
33
|
-
],[], (filepath: string, name: string) => ({
|
|
33
|
+
`!**/Template/**.vue`
|
|
34
|
+
], [], (filepath: string, name: string) => ({
|
|
34
35
|
originalName: name,
|
|
35
36
|
name: name.startsWith("Lib") ? name.replace("Lib", "PREFIX") : `PREFIX${name}`,
|
|
36
|
-
filepath
|
|
37
|
+
filepath
|
|
37
38
|
}))
|
|
38
39
|
|
|
39
40
|
declare module "@nuxt/schema" {
|
|
@@ -42,7 +43,6 @@ declare module "@nuxt/schema" {
|
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
|
|
46
46
|
export interface ModuleOptions {
|
|
47
47
|
/**
|
|
48
48
|
* Whether to include the vite unplugin-icons plugins (pre-configured with the ui module's defaults.
|
|
@@ -71,18 +71,18 @@ export interface ModuleOptions {
|
|
|
71
71
|
export default defineNuxtModule<ModuleOptions>({
|
|
72
72
|
meta: {
|
|
73
73
|
name: "witchcraftUi",
|
|
74
|
-
configKey: "witchcraftUi"
|
|
74
|
+
configKey: "witchcraftUi"
|
|
75
75
|
},
|
|
76
76
|
defaults: {
|
|
77
77
|
includeUnpluginIconsPlugins: true,
|
|
78
|
-
directives: [
|
|
78
|
+
directives: [...knownDirectives],
|
|
79
79
|
globalComponents: [
|
|
80
|
-
...componentsInfo.map(_ => _.name.slice("PREFIX".length))
|
|
80
|
+
...componentsInfo.map(_ => _.name.slice("PREFIX".length))
|
|
81
81
|
],
|
|
82
82
|
componentPrefix: "W",
|
|
83
83
|
debug: true,
|
|
84
84
|
mainCssFile: "~/assets/css/tailwind.css",
|
|
85
|
-
_playgroundWorkaround: false
|
|
85
|
+
_playgroundWorkaround: false
|
|
86
86
|
},
|
|
87
87
|
async setup(options, nuxt) {
|
|
88
88
|
const moduleName = "@witchcraft/ui"
|
|
@@ -97,7 +97,6 @@ export default defineNuxtModule<ModuleOptions>({
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
|
|
101
100
|
const unknownDirectives = options.directives.filter(_ => !knownDirectives.includes(_))
|
|
102
101
|
if (unknownDirectives.length > 0) {
|
|
103
102
|
throw new Error(`Witchcraft Components: Directives list contains unknown directives: ${unknownDirectives.join(",")}`)
|
|
@@ -105,11 +104,10 @@ export default defineNuxtModule<ModuleOptions>({
|
|
|
105
104
|
nuxt.options.runtimeConfig.public.witchcraftUi = defu(
|
|
106
105
|
nuxt.options.runtimeConfig.public.witchcraftUi,
|
|
107
106
|
{
|
|
108
|
-
directives: options.directives
|
|
107
|
+
directives: options.directives
|
|
109
108
|
}
|
|
110
109
|
)
|
|
111
110
|
|
|
112
|
-
|
|
113
111
|
addTemplate({
|
|
114
112
|
filename: "witchcraft-ui.css",
|
|
115
113
|
write: true,
|
|
@@ -127,13 +125,12 @@ export default defineNuxtModule<ModuleOptions>({
|
|
|
127
125
|
${indent(filteredComponentsInfo.map(_ => `@source "${_.filepath}";`).join("\n"), 5)}
|
|
128
126
|
`
|
|
129
127
|
})
|
|
130
|
-
|
|
131
|
-
|
|
128
|
+
|
|
132
129
|
await Promise.all(filteredComponentsInfo
|
|
133
130
|
.map(async entry => addComponent({
|
|
134
131
|
filePath: entry.filepath,
|
|
135
132
|
name: entry.name,
|
|
136
|
-
global: options.globalComponents.includes(entry.name.slice(options.componentPrefix.length))
|
|
133
|
+
global: options.globalComponents.includes(entry.name.slice(options.componentPrefix.length))
|
|
137
134
|
}))
|
|
138
135
|
)
|
|
139
136
|
|
|
@@ -142,12 +139,12 @@ export default defineNuxtModule<ModuleOptions>({
|
|
|
142
139
|
const added: string[] = []
|
|
143
140
|
addImportsCustom([
|
|
144
141
|
`${resolve("runtime/composables")}/**/*`,
|
|
145
|
-
`${resolve("runtime/utils")}
|
|
146
|
-
], [],(filePath: string, name: string) => {
|
|
142
|
+
`${resolve("runtime/utils")}/**/*`
|
|
143
|
+
], [], (filePath: string, name: string) => {
|
|
147
144
|
added.push(name)
|
|
148
145
|
return addImports({
|
|
149
146
|
name,
|
|
150
|
-
from: filePath
|
|
147
|
+
from: filePath
|
|
151
148
|
})
|
|
152
149
|
})
|
|
153
150
|
logger.info(`Added imports: ${added.join(", ")}`)
|
|
@@ -161,27 +158,26 @@ export default defineNuxtModule<ModuleOptions>({
|
|
|
161
158
|
options.includeUnpluginIconsPlugins
|
|
162
159
|
? [
|
|
163
160
|
// we must prepend or the custom style options don't work when the module is used
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
161
|
+
ViteComponents({
|
|
162
|
+
resolvers: [
|
|
163
|
+
IconsResolver({ prefix: "i" })
|
|
164
|
+
]
|
|
165
|
+
})
|
|
169
166
|
// Icons({
|
|
170
167
|
// compiler: "vue3",
|
|
171
168
|
// ...unpluginIconViteOptions,
|
|
172
169
|
// }),
|
|
173
|
-
|
|
170
|
+
]
|
|
174
171
|
: []
|
|
175
172
|
),
|
|
176
173
|
tailwindcss() as any,
|
|
177
|
-
...config.plugins
|
|
174
|
+
...config.plugins
|
|
178
175
|
]
|
|
176
|
+
config.optimizeDeps ??= {}
|
|
177
|
+
config.optimizeDeps.exclude ??= []
|
|
178
|
+
config.optimizeDeps.exclude.push("~icons")
|
|
179
179
|
}
|
|
180
180
|
})
|
|
181
|
-
nuxt.options.vite ||= {}
|
|
182
|
-
nuxt.options.vite.optimizeDeps ??= {}
|
|
183
|
-
nuxt.options.vite.optimizeDeps.exclude ??= []
|
|
184
|
-
nuxt.options.vite.optimizeDeps.exclude.push("~icons")
|
|
185
181
|
const mainCssFile = await resolvePath(options.mainCssFile!, nuxt.options.alias)
|
|
186
182
|
|
|
187
183
|
const exists = fs.existsSync(mainCssFile)
|
|
@@ -199,7 +195,7 @@ export default defineNuxtModule<ModuleOptions>({
|
|
|
199
195
|
nuxt.options.alias["#witchcraft-ui-helpers"] = resolve("runtime/helpers")
|
|
200
196
|
addTypeTemplate({
|
|
201
197
|
filename: "types/witchcraft-ui.d.ts",
|
|
202
|
-
getContents: () => fs.readFileSync(resolve("../types/global.d.ts")).toString()
|
|
198
|
+
getContents: () => fs.readFileSync(resolve("../types/global.d.ts")).toString()
|
|
203
199
|
})
|
|
204
|
-
}
|
|
200
|
+
}
|
|
205
201
|
})
|
|
@@ -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
|
}
|
|
@@ -60,37 +60,36 @@
|
|
|
60
60
|
:disabled="disabled"
|
|
61
61
|
ref="inputEl"
|
|
62
62
|
v-model="$value"
|
|
63
|
-
v-bind="{...$.attrs, class: undefined}"
|
|
63
|
+
v-bind="{ ...$.attrs, class: undefined }"
|
|
64
64
|
>
|
|
65
65
|
<slot/> {{ label }}
|
|
66
66
|
</label>
|
|
67
67
|
</div>
|
|
68
68
|
</template>
|
|
69
|
+
|
|
69
70
|
<script setup lang="ts">
|
|
70
|
-
import { type HTMLAttributes, type InputHTMLAttributes,ref
|
|
71
|
+
import { type HTMLAttributes, type InputHTMLAttributes, ref } from "vue"
|
|
71
72
|
|
|
72
73
|
import { useDivideAttrs } from "../../composables/useDivideAttrs.js"
|
|
73
74
|
import { usePreHydrationValue } from "../../composables/usePreHydrationValue.js"
|
|
74
75
|
import { twMerge } from "../../utils/twMerge.js"
|
|
75
|
-
import { type BaseInteractiveProps, getFallbackId,type LabelProps, type LinkableByIdProps, type TailwindClassProp, type WrapperProps } from "../shared/props.js"
|
|
76
|
+
import { type BaseInteractiveProps, getFallbackId, type LabelProps, type LinkableByIdProps, type TailwindClassProp, type WrapperProps } from "../shared/props.js"
|
|
76
77
|
|
|
77
78
|
defineOptions({
|
|
78
|
-
name: "
|
|
79
|
-
inheritAttrs: false
|
|
79
|
+
name: "LibCheckbox",
|
|
80
|
+
inheritAttrs: false
|
|
80
81
|
})
|
|
81
82
|
|
|
82
83
|
const $ = useDivideAttrs(["label", "wrapper"])
|
|
83
|
-
const $slots = useSlots()
|
|
84
84
|
/* todo multi states */
|
|
85
85
|
|
|
86
86
|
const fallbackId = getFallbackId()
|
|
87
87
|
const props = withDefaults(defineProps<Props>(), {
|
|
88
|
-
unstyle: false, disabled: false, readonly: false, border: true
|
|
88
|
+
unstyle: false, disabled: false, readonly: false, border: true
|
|
89
89
|
})
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
/* User presses enter.*/
|
|
91
|
+
/* const emits = */defineEmits<{
|
|
92
|
+
/* User presses enter. */
|
|
94
93
|
(e: "submit", val: boolean): void
|
|
95
94
|
}>()
|
|
96
95
|
|
|
@@ -102,20 +101,19 @@ usePreHydrationValue(props.id ?? fallbackId, $value)
|
|
|
102
101
|
</script>
|
|
103
102
|
|
|
104
103
|
<script lang="ts">
|
|
105
|
-
|
|
106
|
-
type WrapperTypes = Partial<WrapperProps<"label",HTMLAttributes, {
|
|
104
|
+
type WrapperTypes = Partial<WrapperProps<"label", HTMLAttributes, {
|
|
107
105
|
/** Tailwind classes. */
|
|
108
106
|
class?: string
|
|
109
107
|
}>>
|
|
110
108
|
|
|
111
|
-
type RealProps
|
|
109
|
+
type RealProps
|
|
112
110
|
|
|
113
|
-
& LinkableByIdProps
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
111
|
+
= & LinkableByIdProps
|
|
112
|
+
& LabelProps
|
|
113
|
+
& BaseInteractiveProps
|
|
114
|
+
& {
|
|
115
|
+
unstyle?: boolean
|
|
116
|
+
}
|
|
119
117
|
|
|
120
118
|
interface Props
|
|
121
119
|
extends
|