@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
|
@@ -5,22 +5,19 @@ import { computed, ref, watch } from "vue"
|
|
|
5
5
|
import LibPopup from "./LibPopup.vue"
|
|
6
6
|
|
|
7
7
|
import { vExtractRootEl } from "../../directives/vExtractRootEl.js"
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
9
8
|
import * as components from "../index.js"
|
|
10
9
|
|
|
11
|
-
|
|
12
10
|
const meta: Meta<typeof LibPopup> = {
|
|
13
11
|
component: LibPopup,
|
|
14
12
|
title: "Components/Popup",
|
|
15
13
|
args: {
|
|
16
14
|
|
|
17
|
-
}
|
|
15
|
+
}
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
export default meta
|
|
21
19
|
type Story = StoryObj<typeof LibPopup>
|
|
22
20
|
|
|
23
|
-
|
|
24
21
|
export const Primary: Story = {
|
|
25
22
|
render: args => ({
|
|
26
23
|
components,
|
|
@@ -51,13 +48,12 @@ export const Primary: Story = {
|
|
|
51
48
|
}
|
|
52
49
|
})
|
|
53
50
|
|
|
54
|
-
|
|
55
51
|
return {
|
|
56
52
|
args,
|
|
57
53
|
buttonPos,
|
|
58
54
|
autoRotatePos,
|
|
59
55
|
buttonStyle,
|
|
60
|
-
value
|
|
56
|
+
value
|
|
61
57
|
}
|
|
62
58
|
},
|
|
63
59
|
template: `
|
|
@@ -91,22 +87,22 @@ export const Primary: Story = {
|
|
|
91
87
|
</template>
|
|
92
88
|
</lib-popup>
|
|
93
89
|
</div>
|
|
94
|
-
|
|
95
|
-
})
|
|
90
|
+
`
|
|
91
|
+
})
|
|
96
92
|
}
|
|
97
93
|
export const PopupNoShift = {
|
|
98
94
|
...Primary,
|
|
99
95
|
args: {
|
|
100
|
-
avoidRepositioning: true
|
|
101
|
-
|
|
96
|
+
avoidRepositioning: true
|
|
97
|
+
|
|
102
98
|
}
|
|
103
99
|
}
|
|
104
100
|
/** When the popup is too wide, it's positioned to the left and overflow scroll is set with an invisible scrollbar. */
|
|
105
101
|
export const PopupTooBig = {
|
|
106
102
|
...Primary,
|
|
107
103
|
args: {
|
|
108
|
-
width: "110vw"
|
|
109
|
-
}
|
|
104
|
+
width: "110vw"
|
|
105
|
+
}
|
|
110
106
|
}
|
|
111
107
|
export const PopupCenterScreen = {
|
|
112
108
|
...Primary,
|
|
@@ -114,17 +110,17 @@ export const PopupCenterScreen = {
|
|
|
114
110
|
width: "500px",
|
|
115
111
|
height: "500px",
|
|
116
112
|
preferredHorizontal: ["center-screen"],
|
|
117
|
-
preferredVertical: ["center-screen"]
|
|
118
|
-
}
|
|
113
|
+
preferredVertical: ["center-screen"]
|
|
114
|
+
}
|
|
119
115
|
}
|
|
120
116
|
export const PopupRightBottomMost = {
|
|
121
117
|
...Primary,
|
|
122
118
|
args: {
|
|
123
119
|
width: "500px",
|
|
124
120
|
height: "500px",
|
|
125
|
-
preferredHorizontal: [
|
|
126
|
-
preferredVertical: [
|
|
127
|
-
}
|
|
121
|
+
preferredHorizontal: ["right-most"],
|
|
122
|
+
preferredVertical: ["bottom-most"]
|
|
123
|
+
}
|
|
128
124
|
}
|
|
129
125
|
export const PopupLeftTopMost = {
|
|
130
126
|
...Primary,
|
|
@@ -132,8 +128,8 @@ export const PopupLeftTopMost = {
|
|
|
132
128
|
width: "500px",
|
|
133
129
|
height: "500px",
|
|
134
130
|
preferredHorizontal: ["left-most"],
|
|
135
|
-
preferredVertical: ["top-most"]
|
|
136
|
-
}
|
|
131
|
+
preferredVertical: ["top-most"]
|
|
132
|
+
}
|
|
137
133
|
}
|
|
138
134
|
|
|
139
135
|
export const PopupCenterMost = {
|
|
@@ -142,8 +138,8 @@ export const PopupCenterMost = {
|
|
|
142
138
|
width: "500px",
|
|
143
139
|
height: "500px",
|
|
144
140
|
preferredHorizontal: ["center-most"],
|
|
145
|
-
preferredVertical: ["center-most"]
|
|
146
|
-
}
|
|
141
|
+
preferredVertical: ["center-most"]
|
|
142
|
+
}
|
|
147
143
|
}
|
|
148
144
|
export const LeftMenuShapeExample = {
|
|
149
145
|
...Primary,
|
|
@@ -152,6 +148,6 @@ export const LeftMenuShapeExample = {
|
|
|
152
148
|
height: "500px",
|
|
153
149
|
preferredHorizontal: ["left-most"],
|
|
154
150
|
preferredVertical: ["center-most"],
|
|
155
|
-
avoidRepositioning: true
|
|
156
|
-
}
|
|
151
|
+
avoidRepositioning: true
|
|
152
|
+
}
|
|
157
153
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<!-- Popover API WHEN :sob:
|
|
2
2
|
#awaiting https://developer.mozilla.org/en-US/docs/Web/API/Popover_API#browser_compatibility -->
|
|
3
3
|
<template>
|
|
4
|
-
<slot
|
|
5
|
-
|
|
4
|
+
<slot
|
|
5
|
+
name="button"
|
|
6
|
+
:extract-el="(_:any) => buttonEl = _"
|
|
6
7
|
/>
|
|
7
8
|
<!-- <Transition> -->
|
|
8
9
|
<component
|
|
@@ -23,12 +24,13 @@
|
|
|
23
24
|
`,
|
|
24
25
|
$attrs.class as any
|
|
25
26
|
)"
|
|
26
|
-
v-bind="{...$attrs, class:undefined}"
|
|
27
|
+
v-bind="{ ...$attrs, class: undefined }"
|
|
27
28
|
:is="useDialogForBackdrop ? 'dialog' : 'div'"
|
|
28
29
|
ref="dialogEl"
|
|
29
30
|
@mousedown.self="handleMouseup"
|
|
30
31
|
>
|
|
31
|
-
<div
|
|
32
|
+
<div
|
|
33
|
+
v-if="modelValue"
|
|
32
34
|
:class="`popup z-100 fixed ${props.avoidRepositioning ? 'transition-[top,left]' : ''}`"
|
|
33
35
|
:style="`
|
|
34
36
|
top:${pos.y}px;
|
|
@@ -49,13 +51,13 @@
|
|
|
49
51
|
|
|
50
52
|
<script setup lang="ts">
|
|
51
53
|
// eslint-disable-next-line simple-import-sort/imports
|
|
52
|
-
import { onMounted,
|
|
54
|
+
import { onMounted, ref, useAttrs, watch, type HTMLAttributes } from "vue"
|
|
53
55
|
import { getFallbackId, type LinkableByIdProps, type TailwindClassProp, type PopupProps } from "../shared/props.js"
|
|
54
56
|
|
|
55
57
|
import { twMerge } from "../../utils/twMerge.js"
|
|
56
58
|
import { castType } from "@alanscodelog/utils/castType"
|
|
57
59
|
import { isArray } from "@alanscodelog/utils/isArray"
|
|
58
|
-
import type { IPopupReference, PopupPosition,
|
|
60
|
+
import type { IPopupReference, PopupPosition, SimpleDOMRect } from "../../types/index.js"
|
|
59
61
|
|
|
60
62
|
const fallbackId = getFallbackId()
|
|
61
63
|
const props = withDefaults(defineProps<Props>(), {
|
|
@@ -63,13 +65,13 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
63
65
|
useDialogForBackdrop: false,
|
|
64
66
|
// vue is getting confused when the prop type can also be a function
|
|
65
67
|
preferredHorizontal: () => ["center-most", "either"] satisfies Props["preferredHorizontal"],
|
|
66
|
-
preferredVertical: () => ["top", "bottom", "either"] satisfies Props["preferredVertical"]
|
|
68
|
+
preferredVertical: () => ["top", "bottom", "either"] satisfies Props["preferredVertical"],
|
|
67
69
|
avoidRepositioning: false,
|
|
68
|
-
canClose: true
|
|
70
|
+
canClose: true
|
|
69
71
|
})
|
|
70
72
|
const $attrs = useAttrs()
|
|
71
73
|
defineOptions({
|
|
72
|
-
name: "
|
|
74
|
+
name: "LibPopup",
|
|
73
75
|
inheritAttrs: false
|
|
74
76
|
})
|
|
75
77
|
|
|
@@ -77,7 +79,6 @@ const emit = defineEmits<{
|
|
|
77
79
|
(e: "close"): void
|
|
78
80
|
}>()
|
|
79
81
|
|
|
80
|
-
|
|
81
82
|
const dialogEl = ref<HTMLDialogElement | null>(null)
|
|
82
83
|
const popupEl = ref<IPopupReference | null>(null)
|
|
83
84
|
const buttonEl = ref<IPopupReference | null>(null)
|
|
@@ -87,7 +88,6 @@ const pos = ref<PopupPosition>({} as any)
|
|
|
87
88
|
const modelValue = defineModel<boolean>({ default: false })
|
|
88
89
|
let isOpen = false
|
|
89
90
|
|
|
90
|
-
|
|
91
91
|
/**
|
|
92
92
|
* We don't have access to the dialog backdrop and without extra styling, it's of 0 width/height, positioned in the center of the screen, with margins taking up all the space.
|
|
93
93
|
*
|
|
@@ -101,19 +101,19 @@ const getDialogBoundingRect = (): SimpleDOMRect => ({
|
|
|
101
101
|
top: 0,
|
|
102
102
|
bottom: 0,
|
|
103
103
|
left: 0,
|
|
104
|
-
right: 0
|
|
104
|
+
right: 0
|
|
105
105
|
})
|
|
106
106
|
let lastButtonElPos: SimpleDOMRect | undefined
|
|
107
107
|
const recompute = (force: boolean = false): void => {
|
|
108
108
|
requestAnimationFrame(() => {
|
|
109
109
|
const horzHasCenterScreen = isArray(props.preferredHorizontal)
|
|
110
|
-
|
|
110
|
+
&& props.preferredHorizontal[0] === "center-screen"
|
|
111
111
|
const vertHasCenterScreen = isArray(props.preferredVertical)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const canBePositionedWithoutButton
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
&& props.preferredVertical[0] === "center-screen"
|
|
113
|
+
|
|
114
|
+
const canBePositionedWithoutButton
|
|
115
|
+
= (horzHasCenterScreen || typeof props.preferredHorizontal === "function")
|
|
116
|
+
&& (vertHasCenterScreen || typeof props.preferredVertical === "function")
|
|
117
117
|
if (!popupEl.value || !dialogEl.value || (!buttonEl.value && !canBePositionedWithoutButton)) {
|
|
118
118
|
pos.value = {} as any
|
|
119
119
|
return
|
|
@@ -128,7 +128,6 @@ const recompute = (force: boolean = false): void => {
|
|
|
128
128
|
|
|
129
129
|
let finalPos: { x: number, y: number, maxWidth?: number, maxHeight?: number } = {} as any
|
|
130
130
|
|
|
131
|
-
|
|
132
131
|
if (!force && modelValue.value && props.avoidRepositioning && buttonEl.value && lastButtonElPos) {
|
|
133
132
|
const shiftX = buttonEl.value.getBoundingClientRect().x - lastButtonElPos.x
|
|
134
133
|
const shiftY = buttonEl.value.getBoundingClientRect().y - lastButtonElPos.y
|
|
@@ -149,7 +148,7 @@ const recompute = (force: boolean = false): void => {
|
|
|
149
148
|
topFromCenter: 0,
|
|
150
149
|
bottomFromCenter: 0,
|
|
151
150
|
top: 0,
|
|
152
|
-
bottom: 0
|
|
151
|
+
bottom: 0
|
|
153
152
|
}
|
|
154
153
|
if (el) {
|
|
155
154
|
space.left = (el.x + el.width) - bg.x
|
|
@@ -169,7 +168,6 @@ const recompute = (force: boolean = false): void => {
|
|
|
169
168
|
if (typeof preferredHorizontal === "function") {
|
|
170
169
|
finalPos.x = preferredHorizontal(el, popup, bg, space)
|
|
171
170
|
} else {
|
|
172
|
-
/* eslint-disable no-labels */
|
|
173
171
|
outerloop:
|
|
174
172
|
for (const type of preferredHorizontal) {
|
|
175
173
|
switch (type) {
|
|
@@ -184,8 +182,8 @@ const recompute = (force: boolean = false): void => {
|
|
|
184
182
|
case "center-most":
|
|
185
183
|
case "center":
|
|
186
184
|
castType<DOMRect>(el)
|
|
187
|
-
if (space.leftFromCenter >= (popup.width / 2)
|
|
188
|
-
|
|
185
|
+
if (space.leftFromCenter >= (popup.width / 2)
|
|
186
|
+
&& space.rightFromCenter >= (popup.width / 2)) {
|
|
189
187
|
finalPos.x = el.x + (el.width / 2) - (popup.width / 2)
|
|
190
188
|
break outerloop
|
|
191
189
|
}
|
|
@@ -216,7 +214,7 @@ const recompute = (force: boolean = false): void => {
|
|
|
216
214
|
} else {
|
|
217
215
|
finalPos.x = bg.x + bg.width - popup.width; break outerloop
|
|
218
216
|
}
|
|
219
|
-
|
|
217
|
+
|
|
220
218
|
case "right":
|
|
221
219
|
castType<DOMRect>(el)
|
|
222
220
|
if (space.right >= popup.width) {
|
|
@@ -284,8 +282,8 @@ const recompute = (force: boolean = false): void => {
|
|
|
284
282
|
case "center-most":
|
|
285
283
|
case "center":
|
|
286
284
|
castType<DOMRect>(el)
|
|
287
|
-
if (space.topFromCenter >= (popup.height / 2)
|
|
288
|
-
|
|
285
|
+
if (space.topFromCenter >= (popup.height / 2)
|
|
286
|
+
&& space.bottomFromCenter >= (popup.height / 2)) {
|
|
289
287
|
finalPos.y = el.y + (el.height / 2) - (popup.height / 2)
|
|
290
288
|
break outerloop
|
|
291
289
|
}
|
|
@@ -313,7 +311,7 @@ const recompute = (force: boolean = false): void => {
|
|
|
313
311
|
}
|
|
314
312
|
finalPos.maxWidth = maxWidth ?? undefined
|
|
315
313
|
finalPos.maxHeight = maxHeight ?? undefined
|
|
316
|
-
|
|
314
|
+
|
|
317
315
|
if (props.modifyPosition) {
|
|
318
316
|
finalPos = props.modifyPosition(finalPos, el, popup, bg, space)
|
|
319
317
|
}
|
|
@@ -369,7 +367,6 @@ watch([modelValue, popupEl], () => {
|
|
|
369
367
|
}
|
|
370
368
|
})
|
|
371
369
|
|
|
372
|
-
|
|
373
370
|
const handleMouseup = ($event: MouseEvent) => {
|
|
374
371
|
$event.preventDefault()
|
|
375
372
|
toggle()
|
|
@@ -385,20 +382,19 @@ defineExpose({
|
|
|
385
382
|
},
|
|
386
383
|
setBackground: (el: IPopupReference | null) => {
|
|
387
384
|
backgroundEl.value = el
|
|
388
|
-
}
|
|
385
|
+
}
|
|
389
386
|
|
|
390
387
|
})
|
|
391
|
-
|
|
392
388
|
</script>
|
|
393
|
-
<script lang="ts">
|
|
394
389
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
&
|
|
390
|
+
<script lang="ts">
|
|
391
|
+
type RealProps
|
|
392
|
+
= & LinkableByIdProps
|
|
393
|
+
& PopupProps
|
|
398
394
|
|
|
399
395
|
interface Props
|
|
400
396
|
extends
|
|
401
397
|
/** @vue-ignore */
|
|
402
|
-
Partial<Omit<HTMLAttributes,"class"> & TailwindClassProp>,
|
|
398
|
+
Partial<Omit<HTMLAttributes, "class"> & TailwindClassProp>,
|
|
403
399
|
RealProps { }
|
|
404
400
|
</script>
|
|
@@ -4,10 +4,8 @@ import { onUnmounted, ref } from "vue"
|
|
|
4
4
|
|
|
5
5
|
import LibProgressBar from "./LibProgressBar.vue"
|
|
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 LibProgressBar> = {
|
|
12
10
|
component: LibProgressBar,
|
|
13
11
|
title: "Components/ProgressBar",
|
|
@@ -16,14 +14,13 @@ const meta: Meta<typeof LibProgressBar> = {
|
|
|
16
14
|
// @ts-expect-error .
|
|
17
15
|
_timeout: 1000,
|
|
18
16
|
_add: 10,
|
|
19
|
-
_start: 50
|
|
20
|
-
}
|
|
17
|
+
_start: 50
|
|
18
|
+
}
|
|
21
19
|
}
|
|
22
20
|
|
|
23
21
|
export default meta
|
|
24
22
|
type Story = StoryObj<typeof LibProgressBar>
|
|
25
23
|
|
|
26
|
-
|
|
27
24
|
export const Primary: Story = {
|
|
28
25
|
render: args => ({
|
|
29
26
|
components,
|
|
@@ -45,7 +42,7 @@ export const Primary: Story = {
|
|
|
45
42
|
}
|
|
46
43
|
return {
|
|
47
44
|
args: { ...args },
|
|
48
|
-
progress
|
|
45
|
+
progress
|
|
49
46
|
}
|
|
50
47
|
},
|
|
51
48
|
template: `
|
|
@@ -55,28 +52,28 @@ export const Primary: Story = {
|
|
|
55
52
|
<div class="flex w-full">
|
|
56
53
|
<lib-progress-bar class="flex-1" v-bind="args" :progress="progress"></lib-progress-bar>
|
|
57
54
|
</div>
|
|
58
|
-
|
|
59
|
-
})
|
|
55
|
+
`
|
|
56
|
+
})
|
|
60
57
|
}
|
|
61
58
|
export const Secondary: Story = {
|
|
62
59
|
...Primary,
|
|
63
60
|
args: {
|
|
64
|
-
...Primary.args
|
|
65
|
-
}
|
|
61
|
+
...Primary.args
|
|
62
|
+
}
|
|
66
63
|
}
|
|
67
64
|
export const ReallyLongLabel: Story = {
|
|
68
65
|
...Primary,
|
|
69
66
|
args: {
|
|
70
67
|
...Primary.args,
|
|
71
|
-
label: "Really Long Label Label to See Effect Really Long Label Label to See Effect Really Long Label Label to See Effect Really Long Label Label to See Effect"
|
|
72
|
-
}
|
|
68
|
+
label: "Really Long Label Label to See Effect Really Long Label Label to See Effect Really Long Label Label to See Effect Really Long Label Label to See Effect"
|
|
69
|
+
}
|
|
73
70
|
}
|
|
74
71
|
export const Static: Story = {
|
|
75
72
|
...Primary,
|
|
76
73
|
args: {
|
|
77
74
|
...Primary.args,
|
|
78
|
-
progress: 50
|
|
79
|
-
}
|
|
75
|
+
progress: 50
|
|
76
|
+
}
|
|
80
77
|
}
|
|
81
78
|
|
|
82
79
|
export const AutoHiding: Story = {
|
|
@@ -88,7 +85,6 @@ export const AutoHiding: Story = {
|
|
|
88
85
|
_start: 0,
|
|
89
86
|
// keepSpaceWhenHidden: true,
|
|
90
87
|
_timeout: 1000,
|
|
91
|
-
_add: 10
|
|
92
|
-
}
|
|
88
|
+
_add: 10
|
|
89
|
+
}
|
|
93
90
|
}
|
|
94
|
-
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<Transition>
|
|
3
|
-
<div
|
|
3
|
+
<div
|
|
4
|
+
v-if="!hide"
|
|
4
5
|
:id="id ?? fallbackId"
|
|
5
6
|
:class="twMerge(`
|
|
6
7
|
progress-bar
|
|
@@ -35,7 +36,7 @@
|
|
|
35
36
|
before:transition-all
|
|
36
37
|
before:z-1
|
|
37
38
|
before:duration-500
|
|
38
|
-
`,psuedoHide && `
|
|
39
|
+
`, psuedoHide && `
|
|
39
40
|
after:opacity-0
|
|
40
41
|
before:opacity-0
|
|
41
42
|
`, ($attrs as any).class)"
|
|
@@ -45,14 +46,15 @@
|
|
|
45
46
|
:aria-valuenow="clampVal(progress, clamp[0] ?? 0, clamp[1] ?? 100)"
|
|
46
47
|
:aria-valuemin="clamp[0] ?? 0"
|
|
47
48
|
:aria-valuemax="clamp[1] ?? 100"
|
|
48
|
-
v-bind="{...$attrs, class:undefined}"
|
|
49
|
+
v-bind="{ ...$attrs, class: undefined }"
|
|
49
50
|
:style="`--progress: ${clampVal(progress, clamp[0] ?? 0, clamp[1] ?? 100)}%;`"
|
|
50
51
|
>
|
|
51
52
|
<div class="procgress-bar--label-wrapper relative flex-1">
|
|
52
53
|
<span class="before:content-vertical-holder"/>
|
|
53
54
|
<Transition>
|
|
54
55
|
<slot>
|
|
55
|
-
<label
|
|
56
|
+
<label
|
|
57
|
+
v-if="!psuedoHide"
|
|
56
58
|
:for="id"
|
|
57
59
|
class="
|
|
58
60
|
text-bg
|
|
@@ -93,25 +95,26 @@
|
|
|
93
95
|
</div>
|
|
94
96
|
</Transition>
|
|
95
97
|
</template>
|
|
98
|
+
|
|
96
99
|
<script setup lang="ts">
|
|
97
|
-
import {
|
|
100
|
+
import { ref, watch } from "vue"
|
|
98
101
|
|
|
99
102
|
import { twMerge } from "../../utils/twMerge.js"
|
|
100
|
-
import { type BaseInteractiveProps,getFallbackId,type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js"
|
|
103
|
+
import { type BaseInteractiveProps, getFallbackId, type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js"
|
|
101
104
|
|
|
102
105
|
// TODO move to utils
|
|
103
106
|
const clampVal = (n: number, min: number, max: number) => Math.min(Math.max(n, min), max)
|
|
104
107
|
|
|
105
108
|
defineOptions({
|
|
106
|
-
name: "
|
|
107
|
-
inheritAttrs: false
|
|
109
|
+
name: "LibProgressBar",
|
|
110
|
+
inheritAttrs: false
|
|
108
111
|
})
|
|
109
112
|
const fallbackId = getFallbackId()
|
|
110
113
|
const props = withDefaults(defineProps<Props>(), {
|
|
111
114
|
autohideOnComplete: -1,
|
|
112
115
|
keepSpaceWhenHidden: false,
|
|
113
116
|
clamp: () => [0, 100],
|
|
114
|
-
unstyle: false, disabled: false, readonly: false, border: true
|
|
117
|
+
unstyle: false, disabled: false, readonly: false, border: true
|
|
115
118
|
})
|
|
116
119
|
const hide = ref<boolean>(false)
|
|
117
120
|
const psuedoHide = ref<boolean>(false)
|
|
@@ -130,7 +133,7 @@ if (props.autohideOnComplete > -1 && (props.progress >= 100 || props.progress <
|
|
|
130
133
|
watch([
|
|
131
134
|
() => props.progress,
|
|
132
135
|
() => props.keepSpaceWhenHidden,
|
|
133
|
-
() => props.autohideOnComplete
|
|
136
|
+
() => props.autohideOnComplete
|
|
134
137
|
], () => {
|
|
135
138
|
if (props.autohideOnComplete > -1 && (props.progress >= 100 || props.progress < 0)) {
|
|
136
139
|
if (props.keepSpaceWhenHidden) {
|
|
@@ -158,36 +161,36 @@ watch([
|
|
|
158
161
|
psuedoHide.value = false
|
|
159
162
|
}
|
|
160
163
|
}, { immediate: false })
|
|
161
|
-
|
|
162
164
|
</script>
|
|
165
|
+
|
|
163
166
|
<script lang="ts">
|
|
167
|
+
import type { HTMLAttributes } from "vue"
|
|
164
168
|
|
|
165
|
-
type RealProps
|
|
166
|
-
& LinkableByIdProps
|
|
167
|
-
& BaseInteractiveProps
|
|
168
|
-
& LabelProps
|
|
169
|
-
& {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
169
|
+
type RealProps
|
|
170
|
+
= & LinkableByIdProps
|
|
171
|
+
& BaseInteractiveProps
|
|
172
|
+
& LabelProps
|
|
173
|
+
& {
|
|
174
|
+
progress: number
|
|
175
|
+
/** Will auto hide after this given time if progress is 100% or more or less than 0% until progress is set to something else. Disabled (-1) by default. */
|
|
176
|
+
autohideOnComplete?: number
|
|
177
|
+
/**
|
|
178
|
+
* Do not actually hide the element, just leave an unstyled div,
|
|
179
|
+
* so the whole layout doesn't change on completion when autohideOnComplete is set.
|
|
180
|
+
*/
|
|
181
|
+
keepSpaceWhenHidden?: boolean
|
|
182
|
+
/**
|
|
183
|
+
* By default the progress bar is visually clamped to 0-100, even if the value might be something else.
|
|
184
|
+
* You can change what it's clamped to here, to for example,
|
|
185
|
+
* show at least a small sliver of the progress bar when it's still 0.
|
|
186
|
+
*/
|
|
187
|
+
clamp?: [start: number, end: number]
|
|
188
|
+
}
|
|
185
189
|
|
|
186
190
|
interface Props
|
|
187
191
|
extends
|
|
188
192
|
/** @vue-ignore */
|
|
189
|
-
Partial<Omit<HTMLAttributes,"class"> & TailwindClassProp>,
|
|
193
|
+
Partial<Omit<HTMLAttributes, "class"> & TailwindClassProp>,
|
|
190
194
|
RealProps
|
|
191
195
|
{ }
|
|
192
|
-
|
|
193
196
|
</script>
|
|
@@ -3,7 +3,6 @@ import type { Meta, StoryObj } from "@storybook/vue3"
|
|
|
3
3
|
import { ref, watchEffect } from "vue"
|
|
4
4
|
|
|
5
5
|
import { createRecorderHandler, createRecorderWatchEffect } from "../../helpers/storybook.js"
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
7
6
|
import * as components from "../index.js"
|
|
8
7
|
/**
|
|
9
8
|
* This is a special input component designed to record any type of event.
|
|
@@ -18,8 +17,8 @@ const meta: Meta<typeof components.LibRecorder> = {
|
|
|
18
17
|
args: {
|
|
19
18
|
label: "Some Label",
|
|
20
19
|
recordingTitle: "Recording. Press enter or click away to accept. Press escape to cancel.",
|
|
21
|
-
modelValue: "K E Y S"
|
|
22
|
-
}
|
|
20
|
+
modelValue: "K E Y S"
|
|
21
|
+
}
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
export default meta
|
|
@@ -41,7 +40,7 @@ export const Primary: Story = {
|
|
|
41
40
|
recorder,
|
|
42
41
|
recording,
|
|
43
42
|
recordingValue,
|
|
44
|
-
recorderEl
|
|
43
|
+
recorderEl
|
|
45
44
|
}
|
|
46
45
|
},
|
|
47
46
|
template: `
|
|
@@ -54,28 +53,28 @@ export const Primary: Story = {
|
|
|
54
53
|
v-model="modelValue"
|
|
55
54
|
@recorder:click="recording = !recording"
|
|
56
55
|
/>
|
|
57
|
-
|
|
58
|
-
})
|
|
56
|
+
`
|
|
57
|
+
})
|
|
59
58
|
}
|
|
60
59
|
|
|
61
60
|
/** Should not be tabbable or recordable. */
|
|
62
61
|
export const Disabled: Story = {
|
|
63
62
|
...Primary,
|
|
64
63
|
args: {
|
|
65
|
-
disabled: true
|
|
66
|
-
}
|
|
64
|
+
disabled: true
|
|
65
|
+
}
|
|
67
66
|
}
|
|
68
67
|
/** *Should* be tabbable but not recordable. */
|
|
69
68
|
export const Readonly: Story = {
|
|
70
69
|
...Primary,
|
|
71
70
|
args: {
|
|
72
|
-
readonly: true
|
|
73
|
-
}
|
|
71
|
+
readonly: true
|
|
72
|
+
}
|
|
74
73
|
}
|
|
75
74
|
/** Height should not shrink. */
|
|
76
75
|
export const EmptyInitialValue: Story = {
|
|
77
76
|
...Primary,
|
|
78
77
|
args: {
|
|
79
|
-
modelValue: ""
|
|
80
|
-
}
|
|
78
|
+
modelValue: ""
|
|
79
|
+
}
|
|
81
80
|
}
|