@witchcraft/ui 0.2.1-beta.3 → 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 +1 -1
- 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 +25 -28
- 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
|
@@ -4,13 +4,11 @@ import type { Meta, StoryObj } from "@storybook/vue3"
|
|
|
4
4
|
import LibTable from "./LibTable.vue"
|
|
5
5
|
|
|
6
6
|
// todo
|
|
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 LibTable> = {
|
|
12
10
|
component: LibTable,
|
|
13
|
-
title: "Components/Table"
|
|
11
|
+
title: "Components/Table"
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
export default meta
|
|
@@ -26,81 +24,81 @@ export const Primary: Story = {
|
|
|
26
24
|
>
|
|
27
25
|
</lib-table>
|
|
28
26
|
</div>
|
|
29
|
-
|
|
27
|
+
`
|
|
30
28
|
}),
|
|
31
29
|
args: {
|
|
32
30
|
cols: ["prop1", "prop2", "prop3"],
|
|
33
31
|
values: [
|
|
34
32
|
{ prop1: "Item1 Prop 1", prop2: "Item1 Prop 2", prop3: "Item1 Prop 3" },
|
|
35
33
|
{ prop1: "Item2 Prop 1", prop2: "Item2 Prop 2", prop3: "Item2 Prop 3" },
|
|
36
|
-
{ prop1: "Item3 Prop 1", prop2: "Item3 Prop 2", prop3: "Item3 Prop 3" }
|
|
34
|
+
{ prop1: "Item3 Prop 1", prop2: "Item3 Prop 2", prop3: "Item3 Prop 3" }
|
|
37
35
|
],
|
|
38
36
|
colConfig: { prop1: { name: "Header 1" }, prop2: { name: "Header 2" } },
|
|
39
|
-
itemKey: "prop1"
|
|
40
|
-
}
|
|
37
|
+
itemKey: "prop1"
|
|
38
|
+
}
|
|
41
39
|
}
|
|
42
40
|
|
|
43
41
|
export const NoCellBorders: Story = {
|
|
44
42
|
...Primary,
|
|
45
43
|
args: {
|
|
46
44
|
...Primary.args,
|
|
47
|
-
cellBorder: false
|
|
48
|
-
}
|
|
45
|
+
cellBorder: false
|
|
46
|
+
}
|
|
49
47
|
}
|
|
50
48
|
export const NoBorders: Story = {
|
|
51
49
|
...Primary,
|
|
52
50
|
args: {
|
|
53
51
|
...Primary.args,
|
|
54
|
-
border: false
|
|
55
|
-
}
|
|
52
|
+
border: false
|
|
53
|
+
}
|
|
56
54
|
}
|
|
57
55
|
export const NoCellBordersNoBorders: Story = {
|
|
58
56
|
...Primary,
|
|
59
57
|
args: {
|
|
60
58
|
...Primary.args,
|
|
61
59
|
cellBorder: false,
|
|
62
|
-
border: false
|
|
63
|
-
}
|
|
60
|
+
border: false
|
|
61
|
+
}
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
export const SquareBorders: Story = {
|
|
67
65
|
...Primary,
|
|
68
66
|
args: {
|
|
69
67
|
...Primary.args,
|
|
70
|
-
rounded: false
|
|
71
|
-
}
|
|
68
|
+
rounded: false
|
|
69
|
+
}
|
|
72
70
|
}
|
|
73
71
|
export const NoHeader: Story = {
|
|
74
72
|
...Primary,
|
|
75
73
|
args: {
|
|
76
74
|
...Primary.args,
|
|
77
|
-
header: false
|
|
78
|
-
}
|
|
75
|
+
header: false
|
|
76
|
+
}
|
|
79
77
|
}
|
|
80
78
|
export const NoHeaderNoBorders: Story = {
|
|
81
79
|
...Primary,
|
|
82
80
|
args: {
|
|
83
81
|
...Primary.args,
|
|
84
82
|
header: false,
|
|
85
|
-
border: false
|
|
86
|
-
}
|
|
83
|
+
border: false
|
|
84
|
+
}
|
|
87
85
|
}
|
|
88
86
|
export const NoHeaderNoCellBorders: Story = {
|
|
89
87
|
...Primary,
|
|
90
88
|
args: {
|
|
91
89
|
...Primary.args,
|
|
92
90
|
header: false,
|
|
93
|
-
cellBorder: false
|
|
94
|
-
}
|
|
91
|
+
cellBorder: false
|
|
92
|
+
}
|
|
95
93
|
}
|
|
96
94
|
export const FitWidthFalse: Story = {
|
|
97
95
|
...Primary,
|
|
98
96
|
args: {
|
|
99
97
|
...Primary.args,
|
|
100
98
|
resizable: {
|
|
101
|
-
fitWidth: false
|
|
102
|
-
}
|
|
103
|
-
}
|
|
99
|
+
fitWidth: false
|
|
100
|
+
}
|
|
101
|
+
}
|
|
104
102
|
}
|
|
105
103
|
|
|
106
104
|
export const ThreeColSomeColsNotResizable: Story = {
|
|
@@ -122,18 +120,18 @@ export const ThreeColSomeColsNotResizable: Story = {
|
|
|
122
120
|
v-bind="{...args, colConfig:args.colConfig3}"
|
|
123
121
|
>
|
|
124
122
|
</lib-table>
|
|
125
|
-
|
|
123
|
+
`
|
|
126
124
|
}),
|
|
127
125
|
args: {
|
|
128
126
|
cols: ["prop1", "prop2", "prop3"],
|
|
129
127
|
itemKey: "prop1",
|
|
130
128
|
values: [
|
|
131
|
-
{ prop1: "Prop 1", prop2: "Prop 2", prop3: "Prop 3" }
|
|
129
|
+
{ prop1: "Prop 1", prop2: "Prop 2", prop3: "Prop 3" }
|
|
132
130
|
],
|
|
133
131
|
colConfig: { prop1: { name: "No Resize", resizable: false } },
|
|
134
132
|
colConfig2: { prop2: { name: "No Resize", resizable: false } },
|
|
135
|
-
colConfig3: { prop3: { name: "No Resize", resizable: false } }
|
|
136
|
-
} as any
|
|
133
|
+
colConfig3: { prop3: { name: "No Resize", resizable: false } }
|
|
134
|
+
} as any
|
|
137
135
|
}
|
|
138
136
|
export const FourColSomeColsNotResizable: Story = {
|
|
139
137
|
render: args => ({
|
|
@@ -154,17 +152,16 @@ export const FourColSomeColsNotResizable: Story = {
|
|
|
154
152
|
v-bind="{...args, colConfig:args.colConfig3}"
|
|
155
153
|
>
|
|
156
154
|
</lib-table>
|
|
157
|
-
|
|
155
|
+
`
|
|
158
156
|
}),
|
|
159
157
|
args: {
|
|
160
158
|
cols: ["prop1", "prop2", "prop3", "prop4"],
|
|
161
159
|
values: [
|
|
162
|
-
{ prop1: "Prop 1", prop2: "Prop 2", prop3: "Prop 3", prop4: "Prop 4" }
|
|
160
|
+
{ prop1: "Prop 1", prop2: "Prop 2", prop3: "Prop 3", prop4: "Prop 4" }
|
|
163
161
|
],
|
|
164
162
|
itemKey: "prop1",
|
|
165
163
|
colConfig: { prop1: { name: "No Resize", resizable: false }, prop3: { name: "No Resize", resizable: false } },
|
|
166
164
|
colConfig2: { prop2: { name: "No Resize", resizable: false }, prop3: { name: "No Resize", resizable: false } },
|
|
167
|
-
colConfig3: { prop1: { name: "No Resize", resizable: false }, prop4: { name: "No Resize", resizable: false } }
|
|
168
|
-
} as any
|
|
165
|
+
colConfig3: { prop1: { name: "No Resize", resizable: false }, prop4: { name: "No Resize", resizable: false } }
|
|
166
|
+
} as any
|
|
169
167
|
}
|
|
170
|
-
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<!-- Assumes no scrollbars on children -->
|
|
3
|
-
<table
|
|
3
|
+
<table
|
|
4
|
+
:class="twMerge(`table
|
|
4
5
|
table-fixed
|
|
5
6
|
border-separate
|
|
6
7
|
border-spacing-0
|
|
@@ -16,12 +17,12 @@
|
|
|
16
17
|
[&.resizable-cols-error]:cursor-not-allowed
|
|
17
18
|
[&.resizable-cols-error]:user-select-none
|
|
18
19
|
`,
|
|
19
|
-
|
|
20
|
+
cellBorder && `
|
|
20
21
|
[&_td]:border-neutral-500
|
|
21
22
|
[&_td:not(.last-row)]:border-b
|
|
22
23
|
[&_td:not(.first-col)]:border-l
|
|
23
24
|
`,
|
|
24
|
-
|
|
25
|
+
border && `
|
|
25
26
|
[&_thead_td]:bg-neutral-200
|
|
26
27
|
[&_td]:border-neutral-500
|
|
27
28
|
dark:[&_thead_td]:bg-neutral-800
|
|
@@ -31,19 +32,26 @@
|
|
|
31
32
|
[&_td.last-col]:border-r
|
|
32
33
|
[&_td.first-col]:border-l
|
|
33
34
|
`,
|
|
34
|
-
|
|
35
|
+
rounded &&`
|
|
35
36
|
[&_td.br]:rounded-br-sm
|
|
36
37
|
[&_td.bl]:rounded-bl-sm
|
|
37
38
|
[&_td.tr]:rounded-tr-sm
|
|
38
39
|
[&_td.tl]:rounded-tl-sm
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
`,
|
|
41
|
+
($attrs as any).class)"
|
|
41
42
|
v-resizable-cols="resizableOptions"
|
|
42
43
|
>
|
|
43
|
-
<thead
|
|
44
|
+
<thead
|
|
45
|
+
v-if="header"
|
|
46
|
+
class="table--header"
|
|
47
|
+
>
|
|
44
48
|
<tr class="table--row">
|
|
45
|
-
<template
|
|
46
|
-
|
|
49
|
+
<template
|
|
50
|
+
v-for="col, i of cols"
|
|
51
|
+
:key="col"
|
|
52
|
+
>
|
|
53
|
+
<slot
|
|
54
|
+
:name="`header-${col.toString()}`"
|
|
47
55
|
:class="[
|
|
48
56
|
extraClasses[`-1-${i}`],
|
|
49
57
|
'cell table--header-cell',
|
|
@@ -54,8 +62,9 @@
|
|
|
54
62
|
:style="`width:${widths.length > 0 ? widths[i] : ``}; `"
|
|
55
63
|
:col-key="col"
|
|
56
64
|
>
|
|
57
|
-
<td
|
|
58
|
-
|
|
65
|
+
<td
|
|
66
|
+
:class="[
|
|
67
|
+
extraClasses[`-1-${i}`],
|
|
59
68
|
'cell table--header-cell',
|
|
60
69
|
(colConfig as any)[col]?.resizable === false
|
|
61
70
|
? 'no-resize'
|
|
@@ -70,9 +79,15 @@
|
|
|
70
79
|
</tr>
|
|
71
80
|
</thead>
|
|
72
81
|
<tbody class="table--body">
|
|
73
|
-
<template
|
|
82
|
+
<template
|
|
83
|
+
v-for="item, i of values"
|
|
84
|
+
:key="typeof itemKey === 'function' ? itemKey(item) : item[itemKey]"
|
|
85
|
+
>
|
|
74
86
|
<tr class="table--row">
|
|
75
|
-
<template
|
|
87
|
+
<template
|
|
88
|
+
v-for="col, j of cols"
|
|
89
|
+
:key="(typeof itemKey === 'function' ? itemKey(item) : item[itemKey]) + col.toString()"
|
|
90
|
+
>
|
|
76
91
|
<slot
|
|
77
92
|
:name="col"
|
|
78
93
|
:item="item"
|
|
@@ -94,16 +109,15 @@
|
|
|
94
109
|
<script setup lang="ts" generic="T">
|
|
95
110
|
import type { MakeRequired } from "@alanscodelog/utils"
|
|
96
111
|
import { keys } from "@alanscodelog/utils/keys"
|
|
97
|
-
import { computed,
|
|
112
|
+
import { computed, ref, type TableHTMLAttributes } from "vue"
|
|
98
113
|
|
|
99
114
|
import { vResizableCols } from "../../directives/vResizableCols.js"
|
|
100
115
|
import type { ResizableOptions, TableColConfig } from "../../types/index.js"
|
|
101
116
|
import { twMerge } from "../../utils/twMerge.js"
|
|
102
117
|
import type { TailwindClassProp } from "../shared/props.js"
|
|
103
118
|
|
|
104
|
-
|
|
105
119
|
defineOptions({
|
|
106
|
-
name: "
|
|
120
|
+
name: "LibTable"
|
|
107
121
|
})
|
|
108
122
|
|
|
109
123
|
const props = withDefaults(defineProps<Props>(), {
|
|
@@ -115,7 +129,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
115
129
|
border: true,
|
|
116
130
|
cellBorder: true,
|
|
117
131
|
header: true,
|
|
118
|
-
colConfig: () => ({})
|
|
132
|
+
colConfig: () => ({})
|
|
119
133
|
})
|
|
120
134
|
|
|
121
135
|
const widths = ref([])
|
|
@@ -123,7 +137,7 @@ const resizableOptions = computed<MakeRequired<Partial<ResizableOptions>, "colCo
|
|
|
123
137
|
colCount: props.cols.length,
|
|
124
138
|
widths,
|
|
125
139
|
selector: ".cell",
|
|
126
|
-
...props.resizable
|
|
140
|
+
...props.resizable
|
|
127
141
|
}))
|
|
128
142
|
|
|
129
143
|
/* props.values.length instead of `props.values.length - 1` because we're creating an artificial first row for the header */
|
|
@@ -136,7 +150,7 @@ const getExtraClasses = (row: number, col: number, isHeader: boolean): string[]
|
|
|
136
150
|
"first-row": (isHeader || !props.header) && row === 0,
|
|
137
151
|
"last-row": row === props.values.length - 1,
|
|
138
152
|
"first-col": col === 0,
|
|
139
|
-
"last-col": col === props.cols.length - 1
|
|
153
|
+
"last-col": col === props.cols.length - 1
|
|
140
154
|
}
|
|
141
155
|
return keys(res).filter(key => res[key])
|
|
142
156
|
}
|
|
@@ -146,16 +160,16 @@ const extraClasses = computed(() => Object.fromEntries([...Array(props.values.le
|
|
|
146
160
|
.map(col =>
|
|
147
161
|
[
|
|
148
162
|
`${row - 1}-${col}`,
|
|
149
|
-
getExtraClasses(row <= 0 ? 0 : row - 1, col, row === 0).join(" ")
|
|
163
|
+
getExtraClasses(row <= 0 ? 0 : row - 1, col, row === 0).join(" ")
|
|
150
164
|
]))
|
|
151
|
-
.flat()
|
|
165
|
+
.flat()
|
|
152
166
|
))
|
|
153
|
-
|
|
154
167
|
</script>
|
|
168
|
+
|
|
155
169
|
<script lang="ts">
|
|
156
170
|
// generic isn't working here :/
|
|
157
171
|
type T = any
|
|
158
|
-
|
|
172
|
+
|
|
159
173
|
type RealProps = {
|
|
160
174
|
resizable?: Partial<ResizableOptions>
|
|
161
175
|
values?: T[]
|
|
@@ -171,6 +185,6 @@ type RealProps = {
|
|
|
171
185
|
interface Props
|
|
172
186
|
extends
|
|
173
187
|
/** @vue-ignore */
|
|
174
|
-
Partial<Omit<TableHTMLAttributes,"class" | "readonly" | "disabled"> & TailwindClassProp>,
|
|
188
|
+
Partial<Omit<TableHTMLAttributes, "class" | "readonly" | "disabled"> & TailwindClassProp>,
|
|
175
189
|
RealProps { }
|
|
176
190
|
</script>
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
2
|
import type { Meta, StoryObj } from "@storybook/vue3"
|
|
3
3
|
|
|
4
|
-
|
|
5
4
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
6
5
|
const meta: Meta<{}> = {
|
|
7
6
|
title: "Other/Reset",
|
|
8
7
|
args: {
|
|
9
8
|
|
|
10
|
-
}
|
|
9
|
+
}
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
export default meta
|
|
14
13
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
15
14
|
type Story = StoryObj<{}>
|
|
16
15
|
|
|
17
|
-
|
|
18
16
|
export const Primary: Story = {
|
|
19
17
|
render: args => ({
|
|
20
18
|
setup: () => ({ args }),
|
|
@@ -26,7 +24,6 @@ export const Primary: Story = {
|
|
|
26
24
|
<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>
|
|
27
25
|
<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>
|
|
28
26
|
<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>
|
|
29
|
-
|
|
30
|
-
})
|
|
27
|
+
`
|
|
28
|
+
})
|
|
31
29
|
}
|
|
32
|
-
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
2
|
import type { Meta, StoryObj } from "@storybook/vue3"
|
|
3
3
|
|
|
4
|
-
|
|
5
4
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
6
5
|
const meta: Meta<{}> = {
|
|
7
6
|
title: "Other/Scrolling",
|
|
8
7
|
args: {
|
|
9
8
|
|
|
10
|
-
}
|
|
9
|
+
}
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
export default meta
|
|
14
13
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
15
14
|
type Story = StoryObj<{}>
|
|
16
15
|
|
|
17
|
-
|
|
18
16
|
export const Scrollbars: Story = {
|
|
19
17
|
render: args => ({
|
|
20
18
|
setup: () => ({ args }),
|
|
@@ -37,8 +35,8 @@ export const Scrollbars: Story = {
|
|
|
37
35
|
<div class="h-[1000px] w-[1000px]"/>
|
|
38
36
|
</div>
|
|
39
37
|
</div>
|
|
40
|
-
|
|
41
|
-
})
|
|
38
|
+
`
|
|
39
|
+
})
|
|
42
40
|
}
|
|
43
41
|
|
|
44
42
|
export const TextareaResizer: Story = {
|
|
@@ -52,7 +50,6 @@ export const TextareaResizer: Story = {
|
|
|
52
50
|
min-h-[200px]
|
|
53
51
|
[resize:both]
|
|
54
52
|
" />
|
|
55
|
-
|
|
56
|
-
})
|
|
53
|
+
`
|
|
54
|
+
})
|
|
57
55
|
}
|
|
58
|
-
|
|
@@ -8,32 +8,32 @@
|
|
|
8
8
|
<slot/>
|
|
9
9
|
</div>
|
|
10
10
|
</template>
|
|
11
|
+
|
|
11
12
|
<script setup lang="ts">
|
|
12
|
-
|
|
13
|
+
// remove when copying
|
|
14
|
+
// @ts-nocheck this is a templatek
|
|
15
|
+
/* eslint-disable */
|
|
16
|
+
|
|
13
17
|
import { type HTMLAttributes, ref } from "vue"
|
|
14
18
|
|
|
15
19
|
import { twMerge } from "../../utils/twMerge.js"
|
|
16
|
-
import {
|
|
17
|
-
|
|
20
|
+
import type { TailwindClassProp } from "../shared/props.js"
|
|
18
21
|
|
|
19
22
|
defineOptions({
|
|
20
|
-
name: "
|
|
21
|
-
inheritAttrs: false
|
|
23
|
+
name: "LibName", /* todo */
|
|
24
|
+
inheritAttrs: false
|
|
22
25
|
})
|
|
23
26
|
|
|
24
|
-
|
|
25
27
|
// const props = defineProps<{}>({ })
|
|
26
28
|
|
|
27
29
|
const el = ref<null | HTMLElement>(null)
|
|
28
30
|
|
|
29
31
|
const modelValue = defineModel<string>({ required: true })
|
|
30
|
-
|
|
31
|
-
|
|
32
32
|
</script>
|
|
33
33
|
|
|
34
34
|
<script lang="ts">
|
|
35
35
|
export default {
|
|
36
|
-
name: "
|
|
36
|
+
name: "LibName"
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
type RealProps = {
|
|
@@ -43,7 +43,7 @@ interface Props
|
|
|
43
43
|
extends
|
|
44
44
|
/** @vue-ignore */
|
|
45
45
|
Partial<Omit<HTMLAttributes, "class">
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
& TailwindClassProp
|
|
47
|
+
& RealProps
|
|
48
48
|
> { }
|
|
49
49
|
</script>
|
|
@@ -1,38 +1,37 @@
|
|
|
1
|
-
//
|
|
1
|
+
// remove when copying
|
|
2
|
+
// @ts-nocheck this is a templatek
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
|
|
2
5
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
3
6
|
import type { Meta, StoryObj } from "@storybook/vue3"
|
|
4
7
|
|
|
5
8
|
import NAME from "./NAME.vue"
|
|
6
9
|
|
|
7
10
|
// todo, maybe don't do this for perf reasons
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
9
11
|
import * as components from "../index.js"
|
|
10
12
|
|
|
11
|
-
|
|
12
13
|
const meta: Meta<typeof NAME> = {
|
|
13
14
|
component: NAME,
|
|
14
15
|
args: {
|
|
15
16
|
|
|
16
|
-
}
|
|
17
|
+
}
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export default meta
|
|
20
21
|
type Story = StoryObj<typeof NAME>
|
|
21
22
|
|
|
22
|
-
|
|
23
23
|
export const Primary: Story = {
|
|
24
24
|
render: args => ({
|
|
25
25
|
components,
|
|
26
26
|
setup: () => ({ args }),
|
|
27
27
|
template: `
|
|
28
28
|
<NAME v-bind="{...args}">{{args.value}}</NAME>
|
|
29
|
-
|
|
30
|
-
})
|
|
29
|
+
`
|
|
30
|
+
})
|
|
31
31
|
}
|
|
32
32
|
export const Secondary: Story = {
|
|
33
33
|
...Primary,
|
|
34
34
|
args: {
|
|
35
|
-
...Primary.args
|
|
36
|
-
}
|
|
35
|
+
...Primary.args
|
|
36
|
+
}
|
|
37
37
|
}
|
|
38
|
-
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
<!-- Width 100% + 2xmargin in combination with the margins in LibRoot is a bit of a hack so that it looks like there's padding around the content in test mode (for storybook). We can't just absolutely position these controls or they make the container scroll. -->
|
|
3
3
|
<div class="test-controls flex gap-2 p-1 pb-10 -ml-10 w-[calc(100%_+_var(--spacing)*20)]">
|
|
4
4
|
<div class="flex-grow"/>
|
|
5
|
-
<div class="outline-indicator">
|
|
5
|
+
<div class="outline-indicator">
|
|
6
|
+
{{ showOutline ? "Outline Enabled" : "Outline Disabled" }}
|
|
7
|
+
</div>
|
|
6
8
|
<lib-dark-mode-switcher/>
|
|
7
9
|
</div>
|
|
8
10
|
</template>
|
|
@@ -10,10 +12,8 @@
|
|
|
10
12
|
<script setup lang="ts">
|
|
11
13
|
import LibDarkModeSwitcher from "../LibDarkModeSwitcher/LibDarkModeSwitcher.vue"
|
|
12
14
|
|
|
13
|
-
defineOptions({ name: "
|
|
14
|
-
defineProps<
|
|
15
|
+
defineOptions({ name: "TestControls" })
|
|
16
|
+
defineProps<{
|
|
15
17
|
showOutline: boolean
|
|
16
18
|
}>()
|
|
17
|
-
|
|
18
19
|
</script>
|
|
19
|
-
|
|
@@ -2,7 +2,6 @@ import { useId } from "vue"
|
|
|
2
2
|
|
|
3
3
|
import type { PopupPositioner, PopupPositionModifier } from "../../types"
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
export interface LinkableByIdProps {
|
|
7
6
|
/**
|
|
8
7
|
* The id for the input. Uses vue's useId if none provided.
|
|
@@ -19,7 +18,7 @@ export interface ButtonProps {
|
|
|
19
18
|
color?: "warning" | "ok" | "danger" | "primary" | "secondary" | false
|
|
20
19
|
autoTitleFromAria?: boolean
|
|
21
20
|
}
|
|
22
|
-
|
|
21
|
+
|
|
23
22
|
export interface LabelProps {
|
|
24
23
|
/** For the label. Note the component might or might not support an actual label element. If none is supported, this is used for the `aria-label`. */
|
|
25
24
|
label?: string
|
|
@@ -80,7 +79,7 @@ export type SuggestionsProps<T = any> = {
|
|
|
80
79
|
showSelectedValues?: boolean
|
|
81
80
|
}
|
|
82
81
|
export type SuggestionsOptions<T> = SuggestionsProps<T>
|
|
83
|
-
|
|
82
|
+
|
|
84
83
|
export interface SuggestionsEmits<TMultivalue extends boolean = false> {
|
|
85
84
|
(e: "submit", val: string, suggestion?: any, wasRemoved?: boolean): void
|
|
86
85
|
(e: "update:isOpen", val: boolean): void
|
|
@@ -155,7 +154,6 @@ export interface PopupProps {
|
|
|
155
154
|
canClose?: boolean
|
|
156
155
|
}
|
|
157
156
|
|
|
158
|
-
|
|
159
157
|
export type BaseInteractiveProps = {
|
|
160
158
|
/** Default is false. */
|
|
161
159
|
disabled?: boolean
|
|
@@ -185,8 +183,8 @@ export type WrapperProps<TPrefix extends string, T, TOverrides extends Record<st
|
|
|
185
183
|
[P in keyof T as P extends keyof TOverrides
|
|
186
184
|
? never
|
|
187
185
|
: P extends string
|
|
188
|
-
|
|
189
|
-
|
|
186
|
+
? `${TPrefix}${Capitalize<P>}`
|
|
187
|
+
: never
|
|
190
188
|
]: T[P];
|
|
191
189
|
} & {
|
|
192
190
|
[P in keyof TOverrides as P extends string
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
2
1
|
import { expect, userEvent, within } from "@storybook/test"
|
|
3
2
|
|
|
4
3
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -27,10 +26,10 @@ export const playMultipleValues = async ({ canvasElement, args }: { canvasElemen
|
|
|
27
26
|
await expect(canvas.getByTestId("model-value")).toHaveTextContent("D")
|
|
28
27
|
await userEvent.keyboard("{Enter}")
|
|
29
28
|
await expect(canvas.getByTestId("values").textContent)
|
|
30
|
-
.toBe([
|
|
29
|
+
.toBe([...initialValues, "D"].join(", "))
|
|
31
30
|
// empty input does nothing
|
|
32
31
|
await userEvent.clear(input)
|
|
33
32
|
await userEvent.keyboard("{Enter}")
|
|
34
33
|
await expect(canvas.getByTestId("values").textContent)
|
|
35
|
-
.toBe([
|
|
34
|
+
.toBe([...initialValues, "D"].join(", "))
|
|
36
35
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
2
1
|
import { expect, userEvent, within } from "@storybook/test"
|
|
3
2
|
|
|
4
|
-
|
|
5
3
|
export const playBasicSelect = async ({ canvasElement, args }: { canvasElement: HTMLElement, args: any }) => {
|
|
6
4
|
const canvas = within(canvasElement)
|
|
7
5
|
const input = canvas.getByLabelText(args.label ?? "", { selector: "input" })
|
|
@@ -23,7 +21,7 @@ export const playBasicSelect = async ({ canvasElement, args }: { canvasElement:
|
|
|
23
21
|
await expect(canvas.queryByRole("listbox")).toBeNull()
|
|
24
22
|
}
|
|
25
23
|
await userEvent.keyboard("{Backspace}")
|
|
26
|
-
await expect(canvas.queryByRole("option",{ selected: true })).toBeInTheDocument()
|
|
24
|
+
await expect(canvas.queryByRole("option", { selected: true })).toBeInTheDocument()
|
|
27
25
|
await userEvent.clear(input)
|
|
28
26
|
await userEvent.type(input, "unmatched")
|
|
29
27
|
if (!args.suggestionsFilter && !args.values) {
|
|
@@ -55,7 +53,7 @@ export const playBasicSelect = async ({ canvasElement, args }: { canvasElement:
|
|
|
55
53
|
}
|
|
56
54
|
}
|
|
57
55
|
|
|
58
|
-
export const playBasicKeyboardSelect = async ({ canvasElement, args }: { canvasElement: HTMLElement
|
|
56
|
+
export const playBasicKeyboardSelect = async ({ canvasElement, args }: { canvasElement: HTMLElement, args: any }) => {
|
|
59
57
|
const canvas = within(canvasElement)
|
|
60
58
|
const input = canvas.getByLabelText(args.label ?? "", { selector: "input" })
|
|
61
59
|
await userEvent.clear(input)
|
|
@@ -70,9 +68,8 @@ export const playBasicKeyboardSelect = async ({ canvasElement, args }: { canvasE
|
|
|
70
68
|
await userEvent.keyboard("{ArrowUp}")
|
|
71
69
|
await expect(canvas.queryByRole("option", {
|
|
72
70
|
name: args.values ? "C" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
|
73
|
-
selected: true
|
|
71
|
+
selected: true
|
|
74
72
|
})).toBeInTheDocument()
|
|
75
|
-
|
|
76
73
|
|
|
77
74
|
// loops back to the first item
|
|
78
75
|
await userEvent.keyboard("{ArrowDown}")
|
|
@@ -82,12 +79,12 @@ export const playBasicKeyboardSelect = async ({ canvasElement, args }: { canvasE
|
|
|
82
79
|
await userEvent.keyboard("{PageDown}")
|
|
83
80
|
await expect(canvas.queryByRole("option", {
|
|
84
81
|
name: args.values ? "C" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
|
85
|
-
selected: true
|
|
82
|
+
selected: true
|
|
86
83
|
})).toBeInTheDocument()
|
|
87
84
|
// goes to first
|
|
88
85
|
await userEvent.keyboard("{PageUp}")
|
|
89
86
|
await expect(canvas.queryByRole("option", { name: "A", selected: true })).toBeInTheDocument()
|
|
90
|
-
|
|
87
|
+
|
|
91
88
|
const testOpen = async (key: string) => {
|
|
92
89
|
await userEvent.keyboard("{Escape}")
|
|
93
90
|
if (!args.values) {
|
|
@@ -116,4 +113,3 @@ export const playBasicClickSelect = async ({ canvasElement, args }: { canvasElem
|
|
|
116
113
|
// await expect(canvas.getByTestId("values")).toHaveTextContent(/AB$/)
|
|
117
114
|
// }
|
|
118
115
|
}
|
|
119
|
-
|
|
@@ -43,7 +43,7 @@ import { onBeforeUnmount, onMounted, type Ref, ref, watch } from "vue"
|
|
|
43
43
|
// TODO tailwind example/plugin?
|
|
44
44
|
export function useAccesibilityOutline(
|
|
45
45
|
target: Ref<HTMLElement | null>,
|
|
46
|
-
enable: Ref<boolean> = ref(true)
|
|
46
|
+
enable: Ref<boolean> = ref(true)
|
|
47
47
|
): Record<"outline" | "control", Ref<boolean>> {
|
|
48
48
|
const outline = ref(false)
|
|
49
49
|
const awaitingFocus = ref(false)
|
|
@@ -11,7 +11,7 @@ export const useAriaLabel = (
|
|
|
11
11
|
|
|
12
12
|
const aria = computed(() => ({
|
|
13
13
|
"aria-label": labelExists.value ? undefined : props.label,
|
|
14
|
-
"aria-labelledby": labelExists.value ? `label-${id.value}` : undefined
|
|
14
|
+
"aria-labelledby": labelExists.value ? `label-${id.value}` : undefined
|
|
15
15
|
}))
|
|
16
16
|
|
|
17
17
|
onMounted(() => {
|