@witchcraft/ui 0.1.1 → 0.1.3
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.cjs +5 -0
- package/dist/module.d.ts +36 -0
- package/dist/module.json +2 -2
- package/dist/module.mjs +2 -1
- package/dist/runtime/assets/utils.css +1 -1
- package/dist/runtime/components/Aria/Aria.vue +9 -5
- package/dist/runtime/components/Focus.stories.d.ts +11 -0
- package/dist/runtime/components/Focus.stories.js +53 -0
- package/dist/runtime/components/Icon/Icon.vue +30 -10
- package/dist/runtime/components/LibButton/LibButton.stories.d.ts +12 -0
- package/dist/runtime/components/LibButton/LibButton.stories.js +94 -0
- package/dist/runtime/components/LibButton/LibButton.vue +72 -58
- package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.d.ts +14 -0
- package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.js +29 -0
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +74 -48
- package/dist/runtime/components/LibColorInput/LibColorInput.stories.d.ts +7 -0
- package/dist/runtime/components/LibColorInput/LibColorInput.stories.js +58 -0
- package/dist/runtime/components/LibColorInput/LibColorInput.vue +107 -63
- package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.d.ts +9 -0
- package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.js +68 -0
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +352 -271
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.d.ts +7 -0
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.js +36 -0
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +56 -32
- package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.d.ts +11 -0
- package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.js +98 -0
- package/dist/runtime/components/LibDatePicker/LibDatePicker.vue +38 -17
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue +82 -53
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +67 -50
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue +8 -7
- package/dist/runtime/components/LibDebug/LibDebug.stories.d.ts +9 -0
- package/dist/runtime/components/LibDebug/LibDebug.stories.js +46 -0
- package/dist/runtime/components/LibDebug/LibDebug.vue +70 -42
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue +31 -18
- package/dist/runtime/components/LibFileInput/LibFileInput.stories.d.ts +10 -0
- package/dist/runtime/components/LibFileInput/LibFileInput.stories.js +63 -0
- package/dist/runtime/components/LibFileInput/LibFileInput.vue +156 -113
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.stories.d.ts +33 -0
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.stories.js +384 -0
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +241 -215
- package/dist/runtime/components/LibLabel/LibLabel.stories.d.ts +6 -0
- package/dist/runtime/components/LibLabel/LibLabel.stories.js +25 -0
- package/dist/runtime/components/LibLabel/LibLabel.vue +46 -30
- package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.d.ts +23 -0
- package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.js +61 -0
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +58 -44
- package/dist/runtime/components/LibNotifications/LibNotification.stories.d.ts +15 -0
- package/dist/runtime/components/LibNotifications/LibNotification.stories.js +126 -0
- package/dist/runtime/components/LibNotifications/LibNotification.vue +48 -32
- package/dist/runtime/components/LibNotifications/LibNotifications.stories.d.ts +6 -0
- package/dist/runtime/components/LibNotifications/LibNotifications.stories.js +109 -0
- package/dist/runtime/components/LibNotifications/LibNotifications.vue +83 -63
- package/dist/runtime/components/LibPagination/LibPagination.stories.d.ts +6 -0
- package/dist/runtime/components/LibPagination/LibPagination.stories.js +40 -0
- package/dist/runtime/components/LibPagination/LibPagination.vue +111 -67
- package/dist/runtime/components/LibPalette/LibPalette.stories.d.ts +6 -0
- package/dist/runtime/components/LibPalette/LibPalette.stories.js +20 -0
- package/dist/runtime/components/LibPalette/LibPalette.vue +23 -20
- package/dist/runtime/components/LibPopup/LibPopup.stories.d.ts +14 -0
- package/dist/runtime/components/LibPopup/LibPopup.stories.js +147 -0
- package/dist/runtime/components/LibPopup/LibPopup.vue +351 -314
- package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.d.ts +10 -0
- package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.js +81 -0
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +91 -70
- package/dist/runtime/components/LibRecorder/LibRecorder.stories.d.ts +19 -0
- package/dist/runtime/components/LibRecorder/LibRecorder.stories.js +63 -0
- package/dist/runtime/components/LibRecorder/LibRecorder.vue +177 -133
- package/dist/runtime/components/LibRoot/LibRoot.vue +100 -73
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.d.ts +26 -0
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.js +78 -0
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue +77 -49
- package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.d.ts +27 -0
- package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.js +112 -0
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +156 -123
- package/dist/runtime/components/LibTable/LibTable.stories.d.ts +16 -0
- package/dist/runtime/components/LibTable/LibTable.stories.js +156 -0
- package/dist/runtime/components/LibTable/LibTable.vue +99 -63
- package/dist/runtime/components/Reset.stories.d.ts +5 -0
- package/dist/runtime/components/Reset.stories.js +19 -0
- package/dist/runtime/components/Scrolling.stories.d.ts +6 -0
- package/dist/runtime/components/Scrolling.stories.js +44 -0
- package/dist/runtime/components/Template/NAME.vue +36 -15
- package/dist/runtime/components/TestControls/TestControls.vue +9 -6
- package/dist/runtime/composables/useScrollNearContainerEdges.stories.d.ts +7 -0
- package/dist/runtime/composables/useScrollNearContainerEdges.stories.js +85 -0
- package/dist/types.d.mts +6 -2
- package/dist/types.d.ts +7 -0
- package/package.json +11 -5
- package/src/module.ts +2 -1
- package/src/runtime/assets/utils.css +5 -5
- package/src/runtime/components/LibButton/LibButton.vue +2 -6
- package/src/runtime/nuxt/plugins/vue-plugin.ts +1 -1
- package/dist/runtime/components/Aria/Aria.vue.d.ts +0 -5
- package/dist/runtime/components/Icon/Icon.vue.d.ts +0 -21
- package/dist/runtime/components/LibButton/LibButton.vue.d.ts +0 -36
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +0 -42
- package/dist/runtime/components/LibColorInput/LibColorInput.vue.d.ts +0 -63
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue.d.ts +0 -61
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue.d.ts +0 -22
- package/dist/runtime/components/LibDatePicker/LibDatePicker.vue.d.ts +0 -40
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue.d.ts +0 -34
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue.d.ts +0 -34
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue.d.ts +0 -22
- package/dist/runtime/components/LibDebug/LibDebug.vue.d.ts +0 -32
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue.d.ts +0 -22
- package/dist/runtime/components/LibFileInput/LibFileInput.vue.d.ts +0 -43
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue.d.ts +0 -165
- package/dist/runtime/components/LibLabel/LibLabel.vue.d.ts +0 -27
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue.d.ts +0 -29
- package/dist/runtime/components/LibNotifications/LibNotification.vue.d.ts +0 -17
- package/dist/runtime/components/LibNotifications/LibNotifications.vue.d.ts +0 -13
- package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +0 -104
- package/dist/runtime/components/LibPalette/LibPalette.vue.d.ts +0 -14
- package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +0 -46
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue.d.ts +0 -41
- package/dist/runtime/components/LibRecorder/LibRecorder.vue.d.ts +0 -77
- package/dist/runtime/components/LibRoot/LibRoot.vue.d.ts +0 -41
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue.d.ts +0 -35
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +0 -94
- package/dist/runtime/components/LibTable/LibTable.vue.d.ts +0 -45
- package/dist/runtime/components/Template/NAME.vue.d.ts +0 -17
- package/dist/runtime/components/TestControls/TestControls.vue.d.ts +0 -5
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<!-- Assumes no scrollbars on children -->
|
|
3
|
-
<table :class="twMerge(
|
|
4
|
-
`table
|
|
3
|
+
<table :class="twMerge(`table
|
|
5
4
|
table-fixed
|
|
6
5
|
border-separate
|
|
7
6
|
border-spacing-0
|
|
@@ -17,12 +16,12 @@
|
|
|
17
16
|
[&.resizable-cols-error]:cursor-not-allowed
|
|
18
17
|
[&.resizable-cols-error]:user-select-none
|
|
19
18
|
`,
|
|
20
|
-
|
|
19
|
+
cellBorder && `
|
|
21
20
|
[&_td]:border-neutral-500
|
|
22
21
|
[&_td:not(.last-row)]:border-b
|
|
23
22
|
[&_td:not(.first-col)]:border-l
|
|
24
23
|
`,
|
|
25
|
-
|
|
24
|
+
border && `
|
|
26
25
|
[&_thead_td]:bg-neutral-200
|
|
27
26
|
[&_td]:border-neutral-500
|
|
28
27
|
dark:[&_thead_td]:bg-neutral-800
|
|
@@ -32,14 +31,13 @@
|
|
|
32
31
|
[&_td.last-col]:border-r
|
|
33
32
|
[&_td.first-col]:border-l
|
|
34
33
|
`,
|
|
35
|
-
|
|
34
|
+
rounded &&`
|
|
36
35
|
[&_td.br]:rounded-br-sm
|
|
37
36
|
[&_td.bl]:rounded-bl-sm
|
|
38
37
|
[&_td.tr]:rounded-tr-sm
|
|
39
38
|
[&_td.tl]:rounded-tl-sm
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
)"
|
|
39
|
+
`
|
|
40
|
+
, ($attrs as any).class)"
|
|
43
41
|
v-resizable-cols="resizableOptions"
|
|
44
42
|
>
|
|
45
43
|
<thead v-if="header" class="table--header">
|
|
@@ -47,21 +45,25 @@
|
|
|
47
45
|
<template v-for="col,i of cols" :key="col">
|
|
48
46
|
<slot :name="`header-${col.toString()}`"
|
|
49
47
|
:class="[
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
extraClasses[`-1-${i}`],
|
|
49
|
+
'cell table--header-cell',
|
|
50
|
+
(colConfig as any)[col]?.resizable === false
|
|
51
|
+
? 'no-resize'
|
|
52
|
+
: ''
|
|
53
|
+
].join(' ')"
|
|
54
54
|
:style="`width:${widths.length > 0 ? widths[i] : ``}; `"
|
|
55
55
|
:col-key="col"
|
|
56
56
|
>
|
|
57
57
|
<td :class="[
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
extraClasses[`-1-${i}`] ,
|
|
59
|
+
'cell table--header-cell',
|
|
60
|
+
(colConfig as any)[col]?.resizable === false
|
|
61
|
+
? 'no-resize'
|
|
62
|
+
: ''
|
|
63
|
+
].join(' ')"
|
|
62
64
|
:style="`width:${widths.length > 0 ? widths[i] : ``}; `"
|
|
63
65
|
>
|
|
64
|
-
{{ colConfig[col]?.name ?? col }}
|
|
66
|
+
{{ (colConfig as any)[col]?.name ?? col }}
|
|
65
67
|
</td>
|
|
66
68
|
</slot>
|
|
67
69
|
</template>
|
|
@@ -88,53 +90,87 @@
|
|
|
88
90
|
</table>
|
|
89
91
|
</template>
|
|
90
92
|
|
|
91
|
-
<
|
|
92
|
-
|
|
93
|
-
import {
|
|
94
|
-
import {
|
|
95
|
-
import {
|
|
93
|
+
<!-- generic="T extends Record<string, any> -->"
|
|
94
|
+
<script setup lang="ts" generic="T">
|
|
95
|
+
import type { MakeRequired } from "@alanscodelog/utils"
|
|
96
|
+
import { keys } from "@alanscodelog/utils/keys.js"
|
|
97
|
+
import { computed, type PropType, ref, type TableHTMLAttributes } from "vue"
|
|
98
|
+
|
|
99
|
+
import { vResizableCols } from "../../directives/vResizableCols.js"
|
|
100
|
+
import type { ResizableOptions, TableColConfig } from "../../types/index.js"
|
|
101
|
+
import { twMerge } from "../../utils/twMerge.js"
|
|
102
|
+
import type { TailwindClassProp } from "../shared/props.js"
|
|
103
|
+
|
|
104
|
+
|
|
96
105
|
defineOptions({
|
|
97
|
-
|
|
98
|
-
})
|
|
99
|
-
const props = defineProps({
|
|
100
|
-
resizable: { type: Object, required: false, default: () => ({}) },
|
|
101
|
-
values: { type: Array, required: false, default: () => [] },
|
|
102
|
-
itemKey: { type: [String, Number, Symbol, Function], required: false, default: "" },
|
|
103
|
-
cols: { type: Array, required: false, default: () => [] },
|
|
104
|
-
rounded: { type: Boolean, required: false, default: true },
|
|
105
|
-
border: { type: Boolean, required: false, default: true },
|
|
106
|
-
cellBorder: { type: Boolean, required: false, default: true },
|
|
107
|
-
header: { type: Boolean, required: false, default: true },
|
|
108
|
-
colConfig: { type: null, required: false, default: () => ({}) }
|
|
109
|
-
});
|
|
110
|
-
const widths = ref([]);
|
|
111
|
-
const resizableOptions = computed(() => ({
|
|
112
|
-
colCount: props.cols.length,
|
|
113
|
-
widths,
|
|
114
|
-
selector: ".cell",
|
|
115
|
-
...props.resizable
|
|
116
|
-
}));
|
|
117
|
-
const getExtraClasses = (row, col, isHeader) => {
|
|
118
|
-
const res = {
|
|
119
|
-
bl: !isHeader && row === props.values.length - 1 && col === 0,
|
|
120
|
-
br: !isHeader && row === props.values.length - 1 && col === props.cols.length - 1,
|
|
121
|
-
tr: (isHeader || !props.header) && row === 0 && col === props.cols.length - 1,
|
|
122
|
-
tl: (isHeader || !props.header) && row === 0 && col === 0,
|
|
123
|
-
"first-row": (isHeader || !props.header) && row === 0,
|
|
124
|
-
"last-row": row === props.values.length - 1,
|
|
125
|
-
"first-col": col === 0,
|
|
126
|
-
"last-col": col === props.cols.length - 1
|
|
127
|
-
};
|
|
128
|
-
return keys(res).filter((key) => res[key]);
|
|
129
|
-
};
|
|
130
|
-
const extraClasses = computed(() => Object.fromEntries(
|
|
131
|
-
[...Array(props.values.length + 1).keys()].map((row) => [...Array(props.cols.length).keys()].map((col) => [
|
|
132
|
-
`${row - 1}-${col}`,
|
|
133
|
-
getExtraClasses(row <= 0 ? 0 : row - 1, col, row === 0).join(" ")
|
|
134
|
-
])).flat()
|
|
135
|
-
));
|
|
136
|
-
</script>
|
|
106
|
+
name: "lib-table",
|
|
107
|
+
})
|
|
137
108
|
|
|
138
|
-
<
|
|
109
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
110
|
+
resizable: () => ({}),
|
|
111
|
+
values: () => [] as T[],
|
|
112
|
+
itemKey: "",
|
|
113
|
+
cols: () => [] as (keyof T)[],
|
|
114
|
+
rounded: true,
|
|
115
|
+
border: true,
|
|
116
|
+
cellBorder: true,
|
|
117
|
+
header: true,
|
|
118
|
+
colConfig: () => ({}) ,
|
|
119
|
+
})
|
|
139
120
|
|
|
121
|
+
const widths = ref([])
|
|
122
|
+
const resizableOptions = computed<MakeRequired<Partial<ResizableOptions>, "colCount" | "widths">>(() => ({
|
|
123
|
+
colCount: props.cols.length,
|
|
124
|
+
widths,
|
|
125
|
+
selector: ".cell",
|
|
126
|
+
...props.resizable,
|
|
127
|
+
}))
|
|
128
|
+
|
|
129
|
+
/* props.values.length instead of `props.values.length - 1` because we're creating an artificial first row for the header */
|
|
130
|
+
const getExtraClasses = (row: number, col: number, isHeader: boolean): string[] => {
|
|
131
|
+
const res = {
|
|
132
|
+
bl: !isHeader && row === props.values.length - 1 && col === 0,
|
|
133
|
+
br: !isHeader && row === props.values.length - 1 && col === props.cols.length - 1,
|
|
134
|
+
tr: (isHeader || !props.header) && row === 0 && col === props.cols.length - 1,
|
|
135
|
+
tl: (isHeader || !props.header) && row === 0 && col === 0,
|
|
136
|
+
"first-row": (isHeader || !props.header) && row === 0,
|
|
137
|
+
"last-row": row === props.values.length - 1,
|
|
138
|
+
"first-col": col === 0,
|
|
139
|
+
"last-col": col === props.cols.length - 1,
|
|
140
|
+
}
|
|
141
|
+
return keys(res).filter(key => res[key])
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const extraClasses = computed(() => Object.fromEntries([...Array(props.values.length + 1).keys()]
|
|
145
|
+
.map(row => [...Array(props.cols.length).keys()]
|
|
146
|
+
.map(col =>
|
|
147
|
+
[
|
|
148
|
+
`${row - 1}-${col}`,
|
|
149
|
+
getExtraClasses(row <= 0 ? 0 : row - 1, col, row === 0).join(" "),
|
|
150
|
+
]))
|
|
151
|
+
.flat(),
|
|
152
|
+
))
|
|
153
|
+
|
|
154
|
+
</script>
|
|
155
|
+
<script lang="ts">
|
|
156
|
+
// generic isn't working here :/
|
|
157
|
+
type T = any
|
|
158
|
+
|
|
159
|
+
type RealProps = {
|
|
160
|
+
resizable?: Partial<ResizableOptions>
|
|
161
|
+
values?: T[]
|
|
162
|
+
itemKey?: keyof T | ((item: T) => string)
|
|
163
|
+
/** Let's the table know the shape of the data since values might be empty. */
|
|
164
|
+
cols?: (keyof T)[]
|
|
165
|
+
rounded?: boolean
|
|
166
|
+
border?: boolean
|
|
167
|
+
cellBorder?: boolean
|
|
168
|
+
header?: boolean
|
|
169
|
+
colConfig?: TableColConfig<T>
|
|
170
|
+
}
|
|
171
|
+
interface Props
|
|
172
|
+
extends
|
|
173
|
+
/** @vue-ignore */
|
|
174
|
+
Partial<Omit<TableHTMLAttributes,"class" | "readonly" | "disabled"> & TailwindClassProp>,
|
|
175
|
+
RealProps { }
|
|
140
176
|
</script>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const meta = {
|
|
2
|
+
title: "Other/Reset",
|
|
3
|
+
args: {}
|
|
4
|
+
};
|
|
5
|
+
export default meta;
|
|
6
|
+
export const Primary = {
|
|
7
|
+
render: (args) => ({
|
|
8
|
+
setup: () => ({ args }),
|
|
9
|
+
template: `
|
|
10
|
+
<h1>h1 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ullamcorper est at dui eleifend, et egestas libero gravida. Phasellus non erat pretium, commodo massa sit amet, accumsan nisl.</h1>
|
|
11
|
+
<h2>h2 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ullamcorper est at dui eleifend, et egestas libero gravida. Phasellus non erat pretium, commodo massa sit amet, accumsan nisl.</h2>
|
|
12
|
+
<h3>h3 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ullamcorper est at dui eleifend, et egestas libero gravida. Phasellus non erat pretium, commodo massa sit amet, accumsan nisl.</h3>
|
|
13
|
+
<h4>h4 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ullamcorper est at dui eleifend, et egestas libero gravida. Phasellus non erat pretium, commodo massa sit amet, accumsan nisl.</h4>
|
|
14
|
+
<h5>h5 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ullamcorper est at dui eleifend, et egestas libero gravida. Phasellus non erat pretium, commodo massa sit amet, accumsan nisl.</h5>
|
|
15
|
+
<h6>h6 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ullamcorper est at dui eleifend, et egestas libero gravida. Phasellus non erat pretium, commodo massa sit amet, accumsan nisl.</h6>
|
|
16
|
+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ullamcorper est at dui eleifend, et egestas libero gravida. Phasellus non erat pretium, commodo massa sit amet, accumsan nisl.</p>
|
|
17
|
+
`
|
|
18
|
+
})
|
|
19
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const meta = {
|
|
2
|
+
title: "Other/Scrolling",
|
|
3
|
+
args: {}
|
|
4
|
+
};
|
|
5
|
+
export default meta;
|
|
6
|
+
export const Scrollbars = {
|
|
7
|
+
render: (args) => ({
|
|
8
|
+
setup: () => ({ args }),
|
|
9
|
+
template: `
|
|
10
|
+
<div
|
|
11
|
+
class="
|
|
12
|
+
relative
|
|
13
|
+
flex
|
|
14
|
+
flex-col
|
|
15
|
+
max-h-[300px]
|
|
16
|
+
max-w-[300px]
|
|
17
|
+
border-2
|
|
18
|
+
border-neutral-500
|
|
19
|
+
"
|
|
20
|
+
|
|
21
|
+
>
|
|
22
|
+
<div
|
|
23
|
+
class="overflow-auto"
|
|
24
|
+
>
|
|
25
|
+
<div class="h-[1000px] w-[1000px]"/>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
`
|
|
29
|
+
})
|
|
30
|
+
};
|
|
31
|
+
export const TextareaResizer = {
|
|
32
|
+
render: (args) => ({
|
|
33
|
+
setup: () => ({ args }),
|
|
34
|
+
template: `
|
|
35
|
+
<textarea class="
|
|
36
|
+
border-2
|
|
37
|
+
border-neutral-500
|
|
38
|
+
min-w-[200px]
|
|
39
|
+
min-h-[200px]
|
|
40
|
+
[resize:both]
|
|
41
|
+
" />
|
|
42
|
+
`
|
|
43
|
+
})
|
|
44
|
+
};
|
|
@@ -1,28 +1,49 @@
|
|
|
1
|
+
<!-- eslint-disable -->
|
|
1
2
|
<template>
|
|
2
3
|
<div :class="twMerge(`
|
|
3
4
|
|
|
4
|
-
`, $attrs.class)"
|
|
5
|
-
v-bind="{
|
|
5
|
+
`, ($attrs as any).class)"
|
|
6
|
+
v-bind="{...$attrs, class:undefined}"
|
|
6
7
|
>
|
|
7
8
|
<slot/>
|
|
8
9
|
</div>
|
|
9
10
|
</template>
|
|
11
|
+
<script setup lang="ts">
|
|
12
|
+
|
|
13
|
+
import { computed, type HTMLAttributes, onBeforeUnmount, onMounted, type PropType, reactive, type Ref, ref, watch } from "vue"
|
|
14
|
+
|
|
15
|
+
import { twMerge } from "../../utils/twMerge.js"
|
|
16
|
+
import { baseInteractiveProps, type TailwindClassProp } from "../shared/props.js"
|
|
17
|
+
|
|
10
18
|
|
|
11
|
-
<script setup>
|
|
12
|
-
import { computed, onBeforeUnmount, onMounted, reactive, ref, watch } from "vue";
|
|
13
|
-
import { twMerge } from "../../utils/twMerge.js";
|
|
14
|
-
import { baseInteractiveProps } from "../shared/props.js";
|
|
15
19
|
defineOptions({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
20
|
+
name: "lib-name", /* todo */
|
|
21
|
+
inheritAttrs: false,
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
// const props = defineProps<{}>({ })
|
|
26
|
+
|
|
27
|
+
const el = ref<null | HTMLElement>(null)
|
|
28
|
+
|
|
29
|
+
const modelValue = defineModel<string>({ required: true })
|
|
30
|
+
|
|
31
|
+
|
|
22
32
|
</script>
|
|
23
33
|
|
|
24
|
-
<script>
|
|
34
|
+
<script lang="ts">
|
|
25
35
|
export default {
|
|
26
|
-
|
|
27
|
-
}
|
|
36
|
+
name: "lib-name",
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
type RealProps = {
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface Props
|
|
43
|
+
extends
|
|
44
|
+
/** @vue-ignore */
|
|
45
|
+
Partial<Omit<HTMLAttributes, "class">
|
|
46
|
+
& TailwindClassProp
|
|
47
|
+
& RealProps
|
|
48
|
+
> { }
|
|
28
49
|
</script>
|
|
@@ -7,10 +7,13 @@
|
|
|
7
7
|
</div>
|
|
8
8
|
</template>
|
|
9
9
|
|
|
10
|
-
<script setup>
|
|
11
|
-
import LibDarkModeSwitcher from "../LibDarkModeSwitcher/LibDarkModeSwitcher.vue"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
<script setup lang="ts">
|
|
11
|
+
import LibDarkModeSwitcher from "../LibDarkModeSwitcher/LibDarkModeSwitcher.vue"
|
|
12
|
+
|
|
13
|
+
defineOptions({ name: "test-controls" })
|
|
14
|
+
defineProps< {
|
|
15
|
+
showOutline: boolean
|
|
16
|
+
}>()
|
|
17
|
+
|
|
16
18
|
</script>
|
|
19
|
+
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { onMounted, ref } from "vue";
|
|
2
|
+
import { useScrollNearContainerEdges } from "./useScrollNearContainerEdges.js";
|
|
3
|
+
import { twMerge } from "../utils/twMerge.js";
|
|
4
|
+
const meta = {
|
|
5
|
+
title: "Composables/ScrollNearContainerEdges"
|
|
6
|
+
};
|
|
7
|
+
export default meta;
|
|
8
|
+
export const Primary = {
|
|
9
|
+
render: (args) => ({
|
|
10
|
+
setup: () => {
|
|
11
|
+
const containerEl = ref(null);
|
|
12
|
+
const {
|
|
13
|
+
resetScrollIndicator,
|
|
14
|
+
scrollEdges,
|
|
15
|
+
endScroll,
|
|
16
|
+
scrollIndicator,
|
|
17
|
+
isScrolling
|
|
18
|
+
} = useScrollNearContainerEdges({
|
|
19
|
+
containerEl,
|
|
20
|
+
scrollMargin: 20,
|
|
21
|
+
outerScrollMargin: 20
|
|
22
|
+
});
|
|
23
|
+
const pos = ref({ x: 0, y: 0 });
|
|
24
|
+
onMounted(() => {
|
|
25
|
+
pos.value.x = containerEl.value.getBoundingClientRect().left;
|
|
26
|
+
pos.value.y = containerEl.value.getBoundingClientRect().top;
|
|
27
|
+
});
|
|
28
|
+
const moveDrag = (e) => {
|
|
29
|
+
pos.value.x = e.clientX;
|
|
30
|
+
pos.value.y = e.clientY;
|
|
31
|
+
scrollEdges(e.clientX, e.clientY);
|
|
32
|
+
};
|
|
33
|
+
const endDrag = (_e) => {
|
|
34
|
+
endScroll();
|
|
35
|
+
document.removeEventListener("mousemove", moveDrag);
|
|
36
|
+
document.removeEventListener("mouseup", endDrag);
|
|
37
|
+
};
|
|
38
|
+
const startDrag = (_e) => {
|
|
39
|
+
document.addEventListener("mousemove", moveDrag);
|
|
40
|
+
document.addEventListener("mouseup", endDrag);
|
|
41
|
+
};
|
|
42
|
+
return {
|
|
43
|
+
args,
|
|
44
|
+
containerEl,
|
|
45
|
+
resetScrollIndicator,
|
|
46
|
+
scrollEdges,
|
|
47
|
+
endScroll,
|
|
48
|
+
startDrag,
|
|
49
|
+
scrollIndicator,
|
|
50
|
+
isScrolling,
|
|
51
|
+
twMerge,
|
|
52
|
+
pos
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
template: `
|
|
56
|
+
<div>
|
|
57
|
+
<p>Scroll the container by dragging the red box (which represents the dragging mouse position).</p>
|
|
58
|
+
<p>It should drag slow, then faster as the mouse nears the edges and scroll indicators should appear on the scrolling edges.</p>
|
|
59
|
+
</div>
|
|
60
|
+
<div
|
|
61
|
+
:class="twMerge(
|
|
62
|
+
'relative flex flex-col max-h-[300px] max-w-[300px] border-2 border-red-500',
|
|
63
|
+
isScrolling && 'after:content-[\\'\\'] after:absolute after:inset-0 after:border-transparent after:border-[15px]',
|
|
64
|
+
scrollIndicator.right && 'after:border-r-accent-500/60',
|
|
65
|
+
scrollIndicator.down && 'after:border-b-accent-500/60',
|
|
66
|
+
scrollIndicator.left && 'after:border-l-accent-500/60',
|
|
67
|
+
scrollIndicator.up && 'after:border-t-accent-500/60',
|
|
68
|
+
)"
|
|
69
|
+
|
|
70
|
+
>
|
|
71
|
+
<div
|
|
72
|
+
class="overflow-auto"
|
|
73
|
+
ref="containerEl"
|
|
74
|
+
>
|
|
75
|
+
<div class="h-[1000px] w-[1000px]"/>
|
|
76
|
+
<div
|
|
77
|
+
@mousedown="startDrag"
|
|
78
|
+
:style="\`top:\${pos.y}px; left:\${pos.x}px;\`"
|
|
79
|
+
class="h-[20px] w-[20px] -ml-[10px] -mt-[10px] bg-red-500 cursor-move fixed"
|
|
80
|
+
></div>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
`
|
|
84
|
+
})
|
|
85
|
+
};
|
package/dist/types.d.mts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { NuxtModule } from '@nuxt/schema'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import type { default as Module } from './module.js'
|
|
4
|
+
|
|
5
|
+
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
|
+
|
|
7
|
+
export { default } from './module.js'
|
package/dist/types.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@witchcraft/ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Vue component library.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/runtime/main.lib.js",
|
|
@@ -65,8 +65,7 @@
|
|
|
65
65
|
"failOnWarn": false
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
|
68
|
-
"
|
|
69
|
-
"prepare": "husky && pnpm gen:theme && pnpm build",
|
|
68
|
+
"prepare": "husky && pnpm gen:theme && cd playground && pnpm i",
|
|
70
69
|
"build": "nuxt-module-build prepare && nuxt-module-build build && nuxi generate playground",
|
|
71
70
|
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
72
71
|
"dev": "nuxi dev playground",
|
|
@@ -79,7 +78,7 @@
|
|
|
79
78
|
"doc:dev": "pnpm storybook",
|
|
80
79
|
"lint:eslint": "eslint \"src/**/*.{js,ts,vue,cjs}\" \"*.{js,ts}\" --max-warnings=5 --report-unused-disable-directives",
|
|
81
80
|
"lint:types": "vue-tsc --noEmit --pretty --project tsconfig.types.json",
|
|
82
|
-
"lint:commits": "commitlint --from
|
|
81
|
+
"lint:commits": "commitlint --from-last-tag --to HEAD --verbose",
|
|
83
82
|
"lint:imports": "madge --circular --extensions ts ./src",
|
|
84
83
|
"lint": "pnpm lint:types && pnpm lint:eslint",
|
|
85
84
|
"//actions:debug": "echo For debugging github build action locally with nektos/act. Requires act and docker. Note: Cache will never work locally because of https://github.com/nektos/act/issues/285",
|
|
@@ -88,7 +87,9 @@
|
|
|
88
87
|
"gen:theme": "echo src/runtime/build/generateTheme.ts"
|
|
89
88
|
},
|
|
90
89
|
"peerDependencies": {
|
|
90
|
+
"@iconify/json": "^2.2.323",
|
|
91
91
|
"tailwindcss": "^4.0.17",
|
|
92
|
+
"unplugin-icons": "^22.1.0",
|
|
92
93
|
"vue": "^3.2.47"
|
|
93
94
|
},
|
|
94
95
|
"peerDependenciesMeta": {
|
|
@@ -129,7 +130,7 @@
|
|
|
129
130
|
"@commitlint/cli": "^19.3.0",
|
|
130
131
|
"@internationalized/date": "^3.1.0",
|
|
131
132
|
"@nuxt/eslint-config": "^1.3.0",
|
|
132
|
-
"@nuxt/module-builder": "^
|
|
133
|
+
"@nuxt/module-builder": "^0.8.4",
|
|
133
134
|
"@nuxtjs/i18n": "^9.5.3",
|
|
134
135
|
"@playwright/test": "=1.50.0",
|
|
135
136
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
@@ -201,5 +202,10 @@
|
|
|
201
202
|
},
|
|
202
203
|
"publishConfig": {
|
|
203
204
|
"access": "public"
|
|
205
|
+
},
|
|
206
|
+
"pnpm": {
|
|
207
|
+
"overrides": {
|
|
208
|
+
"rollup": "=4.45.0"
|
|
209
|
+
}
|
|
204
210
|
}
|
|
205
211
|
}
|
package/src/module.ts
CHANGED
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
useLogger,
|
|
9
9
|
} from "@nuxt/kit"
|
|
10
10
|
import tailwindcss from "@tailwindcss/vite"
|
|
11
|
-
import { addImportsCustom
|
|
11
|
+
import { addImportsCustom } from "@witchcraft/nuxt-utils/utils/addImportsCustom.js"
|
|
12
|
+
import { globFiles } from "@witchcraft/nuxt-utils/utils/globFiles.js"
|
|
12
13
|
import { defu } from "defu"
|
|
13
14
|
import fs from "fs"
|
|
14
15
|
import { themeAsTailwindCss } from "metamorphosis/tailwind"
|
|
@@ -37,17 +37,17 @@
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
@utility focus-outline-within {
|
|
40
|
-
@
|
|
40
|
+
@reference outlined-within:outline-2 outlined-within:outline-accent-500 outlined-within:outline-offset-2;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
@utility focus-outline {
|
|
44
|
-
@
|
|
44
|
+
@reference outlined:outline-2 outlined:outline-accent-500 outlined:outline-offset-2;
|
|
45
45
|
}
|
|
46
46
|
@utility focus-outline-no-offset {
|
|
47
|
-
@
|
|
47
|
+
@reference outlined:outline-2 outlined:outline-accent-500;
|
|
48
48
|
}
|
|
49
49
|
@utility focus-outline-hidden {
|
|
50
|
-
@
|
|
50
|
+
@reference outlined:outline-none;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
/* .bg-squares-gradient { */
|
|
@@ -217,7 +217,7 @@
|
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
@utility bg-transparency-squares {
|
|
220
|
-
@
|
|
220
|
+
@reference bg-squares-gradient square-light-white square-dark-neutral-300 square-size-6;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
@utility link-like {
|
|
@@ -185,15 +185,11 @@
|
|
|
185
185
|
|
|
186
186
|
<script setup lang="ts">
|
|
187
187
|
import { isBlank } from "@alanscodelog/utils/isBlank.js"
|
|
188
|
-
import {
|
|
189
|
-
import { pick } from "@alanscodelog/utils/pick.js"
|
|
190
|
-
import type { MakeRequired } from "@alanscodelog/utils/types"
|
|
191
|
-
import { type ButtonHTMLAttributes,computed, type HTMLAttributes, type PropType,useAttrs } from "vue"
|
|
188
|
+
import { type ButtonHTMLAttributes,computed, useAttrs } from "vue"
|
|
192
189
|
|
|
193
190
|
import { useAriaLabel } from "../../composables/useAriaLabel.js"
|
|
194
|
-
import { useDivideAttrs } from "../../composables/useDivideAttrs.js"
|
|
195
191
|
import { twMerge } from "../../utils/twMerge.js"
|
|
196
|
-
import { type BaseInteractiveProps,
|
|
192
|
+
import { type BaseInteractiveProps, baseInteractivePropsDefaults, type ButtonProps,getFallbackId, type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js"
|
|
197
193
|
|
|
198
194
|
|
|
199
195
|
const $attrs = useAttrs()
|
|
@@ -14,6 +14,6 @@ export default defineNuxtPlugin({
|
|
|
14
14
|
? (await Promise.all(config.directives.map(async (name: string) => (import(`../../directives/${name}.ts`))))).map((_: any) => Object.values(_)[0])
|
|
15
15
|
// @ts-expect-error ts filetype needed for nuxt
|
|
16
16
|
: await import(`../../directives/index.ts`))
|
|
17
|
-
registerDirectives(app, Object.values(directives))
|
|
17
|
+
registerDirectives(app as any, Object.values(directives))
|
|
18
18
|
},
|
|
19
19
|
})
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
type __VLS_Props = {
|
|
2
|
-
value: string;
|
|
3
|
-
};
|
|
4
|
-
declare const _default: import("vue").DefineComponent<__VLS_Props, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
5
|
-
export default _default;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type HTMLAttributes } from "vue";
|
|
2
|
-
/**
|
|
3
|
-
* Just a very simple wrapper for wrapping unplugin-icons in an inline-block div so the icon in the slot take's up a normal line height when it's alone.
|
|
4
|
-
*
|
|
5
|
-
* ```vue
|
|
6
|
-
* <icon><i-...></icon>
|
|
7
|
-
* ``
|
|
8
|
-
*/
|
|
9
|
-
interface Props extends
|
|
10
|
-
/** @vue-ignore */
|
|
11
|
-
Partial<Omit<HTMLAttributes, "class">> {
|
|
12
|
-
}
|
|
13
|
-
declare const _default: __VLS_WithSlots<import("vue").DefineComponent<Props, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
14
|
-
default?: (props: {}) => any;
|
|
15
|
-
}>;
|
|
16
|
-
export default _default;
|
|
17
|
-
type __VLS_WithSlots<T, S> = T & {
|
|
18
|
-
new (): {
|
|
19
|
-
$slots: S;
|
|
20
|
-
};
|
|
21
|
-
};
|