@witchcraft/ui 0.1.3 → 0.2.1-beta.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/README.md +3 -6
- package/dist/module.json +3 -3
- package/dist/module.mjs +15 -12
- package/dist/runtime/build/generateTheme.js +1 -1
- package/dist/runtime/components/Aria/Aria.vue +5 -9
- package/dist/runtime/components/Aria/Aria.vue.d.ts +5 -0
- package/dist/runtime/components/Icon/Icon.vue +10 -30
- package/dist/runtime/components/Icon/Icon.vue.d.ts +21 -0
- package/dist/runtime/components/LibButton/LibButton.vue +51 -72
- package/dist/runtime/components/LibButton/LibButton.vue.d.ts +36 -0
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +43 -74
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +42 -0
- package/dist/runtime/components/LibColorInput/LibColorInput.vue +63 -107
- package/dist/runtime/components/LibColorInput/LibColorInput.vue.d.ts +63 -0
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +272 -352
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue.d.ts +61 -0
- package/dist/runtime/components/LibColorPicker/utils/safeConvertToHsva.js +1 -1
- package/dist/runtime/components/LibColorPicker/utils/safeConvertToRgba.js +1 -1
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +35 -69
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue.d.ts +22 -0
- package/dist/runtime/components/LibDatePicker/LibDatePicker.vue +17 -38
- package/dist/runtime/components/LibDatePicker/LibDatePicker.vue.d.ts +40 -0
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue +58 -82
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue.d.ts +34 -0
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +55 -67
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue.d.ts +34 -0
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue +7 -8
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue.d.ts +22 -0
- package/dist/runtime/components/LibDebug/LibDebug.vue +43 -70
- package/dist/runtime/components/LibDebug/LibDebug.vue.d.ts +32 -0
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue +18 -31
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue.d.ts +22 -0
- package/dist/runtime/components/LibFileInput/LibFileInput.vue +116 -156
- package/dist/runtime/components/LibFileInput/LibFileInput.vue.d.ts +43 -0
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +211 -241
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue.d.ts +165 -0
- package/dist/runtime/components/LibLabel/LibLabel.vue +25 -46
- package/dist/runtime/components/LibLabel/LibLabel.vue.d.ts +26 -0
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +43 -58
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue.d.ts +29 -0
- package/dist/runtime/components/LibNotifications/LibNotification.vue +34 -48
- package/dist/runtime/components/LibNotifications/LibNotification.vue.d.ts +17 -0
- package/dist/runtime/components/LibNotifications/LibNotifications.vue +63 -83
- package/dist/runtime/components/LibNotifications/LibNotifications.vue.d.ts +13 -0
- package/dist/runtime/components/LibPagination/LibPagination.vue +67 -111
- package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +104 -0
- package/dist/runtime/components/LibPalette/LibPalette.vue +17 -23
- package/dist/runtime/components/LibPalette/LibPalette.vue.d.ts +14 -0
- package/dist/runtime/components/LibPopup/LibPopup.vue +314 -351
- package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +46 -0
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +65 -91
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue.d.ts +41 -0
- package/dist/runtime/components/LibRecorder/LibRecorder.vue +127 -177
- package/dist/runtime/components/LibRecorder/LibRecorder.vue.d.ts +77 -0
- package/dist/runtime/components/LibRoot/LibRoot.vue +75 -101
- package/dist/runtime/components/LibRoot/LibRoot.vue.d.ts +41 -0
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue +42 -77
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue.d.ts +35 -0
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +118 -156
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +94 -0
- package/dist/runtime/components/LibTable/LibTable.vue +63 -99
- package/dist/runtime/components/LibTable/LibTable.vue.d.ts +45 -0
- package/dist/runtime/components/Template/NAME.vue +15 -36
- package/dist/runtime/components/Template/NAME.vue.d.ts +17 -0
- package/dist/runtime/components/TestControls/TestControls.vue +6 -9
- package/dist/runtime/components/TestControls/TestControls.vue.d.ts +5 -0
- package/dist/runtime/components/shared/props.d.ts +0 -29
- package/dist/runtime/components/shared/props.js +0 -12
- package/dist/runtime/composables/useAccesibilityOutline.js +1 -1
- package/dist/runtime/composables/useDivideAttrs.js +1 -1
- package/dist/runtime/composables/useSuggestions.js +4 -4
- package/dist/runtime/directives/vDetectFlex.js +4 -4
- package/dist/runtime/directives/vExtractRootEl.d.ts +1 -1
- package/dist/runtime/directives/vResizableCols.d.ts +1 -1
- package/dist/runtime/directives/vResizableCols.js +4 -4
- package/dist/runtime/helpers/NotificationHandler.js +6 -6
- package/dist/runtime/helpers/base64ToImg.js +2 -2
- package/dist/runtime/nuxt/plugins/vue-plugin.js +1 -1
- package/dist/runtime/tailwind/themeConvertionOpts.d.ts +1 -1
- package/dist/runtime/theme.d.ts +1 -1
- package/dist/runtime/theme.js +1 -1
- package/dist/runtime/utils/notifyIfError.js +1 -1
- package/dist/runtime/vue/registerComponents.js +1 -1
- package/dist/types.d.mts +2 -6
- package/package.json +68 -90
- package/src/module.ts +19 -12
- package/src/runtime/build/generateTheme.ts +1 -1
- package/src/runtime/components/LibButton/LibButton.stories.ts +1 -1
- package/src/runtime/components/LibButton/LibButton.vue +3 -3
- package/src/runtime/components/LibCheckbox/LibCheckbox.vue +3 -7
- package/src/runtime/components/LibColorPicker/LibColorPicker.vue +6 -4
- package/src/runtime/components/LibColorPicker/utils/safeConvertToHsva.ts +1 -1
- package/src/runtime/components/LibColorPicker/utils/safeConvertToRgba.ts +1 -1
- package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +8 -15
- package/src/runtime/components/LibDatePicker/LibRangeDatePicker.vue +6 -0
- package/src/runtime/components/LibDatePicker/LibSingleDatePicker.vue +6 -0
- package/src/runtime/components/LibDebug/LibDebug.stories.ts +1 -1
- package/src/runtime/components/LibDebug/LibDebug.vue +2 -0
- package/src/runtime/components/LibFileInput/LibFileInput.vue +4 -0
- package/src/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +7 -5
- package/src/runtime/components/LibLabel/LibLabel.vue +2 -3
- package/src/runtime/components/LibMultiValues/LibMultiValues.vue +5 -3
- package/src/runtime/components/LibNotifications/LibNotification.vue +3 -0
- package/src/runtime/components/LibNotifications/LibNotifications.vue +1 -1
- package/src/runtime/components/LibPalette/LibPalette.vue +3 -3
- package/src/runtime/components/LibPopup/LibPopup.vue +2 -2
- package/src/runtime/components/LibProgressBar/LibProgressBar.vue +2 -2
- package/src/runtime/components/LibRecorder/LibRecorder.vue +3 -3
- package/src/runtime/components/LibRoot/LibRoot.vue +3 -2
- package/src/runtime/components/LibSimpleInput/LibSimpleInput.vue +2 -2
- package/src/runtime/components/LibSuggestions/LibSuggestions.vue +2 -2
- package/src/runtime/components/LibTable/LibTable.vue +1 -1
- package/src/runtime/components/Template/NAME.vue +2 -2
- package/src/runtime/components/shared/props.ts +8 -12
- package/src/runtime/composables/useAccesibilityOutline.ts +1 -1
- package/src/runtime/composables/useDivideAttrs.ts +1 -1
- package/src/runtime/composables/useSuggestions.ts +4 -4
- package/src/runtime/directives/vDetectFlex.ts +4 -4
- package/src/runtime/directives/vExtractRootEl.ts +1 -1
- package/src/runtime/directives/vResizableCols.ts +5 -5
- package/src/runtime/helpers/NotificationHandler.ts +6 -6
- package/src/runtime/nuxt/plugins/vue-plugin.ts +1 -1
- package/src/runtime/tailwind/themeConvertionOpts.ts +1 -1
- package/src/runtime/theme.ts +2 -2
- package/src/runtime/utils/notifyIfError.ts +1 -1
- package/src/runtime/vue/registerComponents.ts +1 -1
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -36
- package/dist/runtime/components/Focus.stories.d.ts +0 -11
- package/dist/runtime/components/Focus.stories.js +0 -53
- package/dist/runtime/components/LibButton/LibButton.stories.d.ts +0 -12
- package/dist/runtime/components/LibButton/LibButton.stories.js +0 -94
- package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.d.ts +0 -14
- package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.js +0 -29
- package/dist/runtime/components/LibColorInput/LibColorInput.stories.d.ts +0 -7
- package/dist/runtime/components/LibColorInput/LibColorInput.stories.js +0 -58
- package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.d.ts +0 -9
- package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.js +0 -68
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.d.ts +0 -7
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.js +0 -36
- package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.d.ts +0 -11
- package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.js +0 -98
- package/dist/runtime/components/LibDebug/LibDebug.stories.d.ts +0 -9
- package/dist/runtime/components/LibDebug/LibDebug.stories.js +0 -46
- package/dist/runtime/components/LibFileInput/LibFileInput.stories.d.ts +0 -10
- package/dist/runtime/components/LibFileInput/LibFileInput.stories.js +0 -63
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.stories.d.ts +0 -33
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.stories.js +0 -384
- package/dist/runtime/components/LibLabel/LibLabel.stories.d.ts +0 -6
- package/dist/runtime/components/LibLabel/LibLabel.stories.js +0 -25
- package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.d.ts +0 -23
- package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.js +0 -61
- package/dist/runtime/components/LibNotifications/LibNotification.stories.d.ts +0 -15
- package/dist/runtime/components/LibNotifications/LibNotification.stories.js +0 -126
- package/dist/runtime/components/LibNotifications/LibNotifications.stories.d.ts +0 -6
- package/dist/runtime/components/LibNotifications/LibNotifications.stories.js +0 -109
- package/dist/runtime/components/LibPagination/LibPagination.stories.d.ts +0 -6
- package/dist/runtime/components/LibPagination/LibPagination.stories.js +0 -40
- package/dist/runtime/components/LibPalette/LibPalette.stories.d.ts +0 -6
- package/dist/runtime/components/LibPalette/LibPalette.stories.js +0 -20
- package/dist/runtime/components/LibPopup/LibPopup.stories.d.ts +0 -14
- package/dist/runtime/components/LibPopup/LibPopup.stories.js +0 -147
- package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.d.ts +0 -10
- package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.js +0 -81
- package/dist/runtime/components/LibRecorder/LibRecorder.stories.d.ts +0 -19
- package/dist/runtime/components/LibRecorder/LibRecorder.stories.js +0 -63
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.d.ts +0 -26
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.js +0 -78
- package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.d.ts +0 -27
- package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.js +0 -112
- package/dist/runtime/components/LibTable/LibTable.stories.d.ts +0 -16
- package/dist/runtime/components/LibTable/LibTable.stories.js +0 -156
- package/dist/runtime/components/Reset.stories.d.ts +0 -5
- package/dist/runtime/components/Reset.stories.js +0 -19
- package/dist/runtime/components/Scrolling.stories.d.ts +0 -6
- package/dist/runtime/components/Scrolling.stories.js +0 -44
- package/dist/runtime/composables/useScrollNearContainerEdges.stories.d.ts +0 -7
- package/dist/runtime/composables/useScrollNearContainerEdges.stories.js +0 -85
- package/dist/types.d.ts +0 -7
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type HTMLAttributes } from "vue";
|
|
2
|
+
import { type LinkableByIdProps, type TailwindClassProp, type PopupProps } from "../shared/props.js.js";
|
|
3
|
+
import type { IPopupReference, PopupPositioner } from "../../types/index.js.js";
|
|
4
|
+
type RealProps = LinkableByIdProps & PopupProps;
|
|
5
|
+
interface Props extends
|
|
6
|
+
/** @vue-ignore */
|
|
7
|
+
Partial<Omit<HTMLAttributes, "class"> & TailwindClassProp>, RealProps {
|
|
8
|
+
}
|
|
9
|
+
declare const _default: __VLS_WithSlots<import("vue").DefineComponent<Props & {
|
|
10
|
+
modelValue?: boolean;
|
|
11
|
+
}, {
|
|
12
|
+
recompute: (force?: boolean) => void;
|
|
13
|
+
setReference: (el: IPopupReference | null) => void;
|
|
14
|
+
setBackground: (el: IPopupReference | null) => void;
|
|
15
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
16
|
+
"update:modelValue": (value: boolean) => any;
|
|
17
|
+
} & {
|
|
18
|
+
close: () => any;
|
|
19
|
+
}, string, import("vue").PublicProps, Readonly<Props & {
|
|
20
|
+
modelValue?: boolean;
|
|
21
|
+
}> & Readonly<{
|
|
22
|
+
"onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
|
|
23
|
+
onClose?: (() => any) | undefined;
|
|
24
|
+
}>, {
|
|
25
|
+
canClose: boolean;
|
|
26
|
+
useDialogForBackdrop: false;
|
|
27
|
+
useBackdrop: boolean;
|
|
28
|
+
preferredHorizontal: ("center" | "right" | "left" | "either" | "center-screen" | "right-most" | "left-most" | "center-most")[] | PopupPositioner;
|
|
29
|
+
preferredVertical: ("top" | "bottom" | "center" | "either" | "center-screen" | "top-most" | "bottom-most" | "center-most")[] | PopupPositioner;
|
|
30
|
+
avoidRepositioning: boolean;
|
|
31
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
32
|
+
button?: (props: {
|
|
33
|
+
extractEl: (_: any) => any;
|
|
34
|
+
}) => any;
|
|
35
|
+
} & {
|
|
36
|
+
popup?: (props: {
|
|
37
|
+
position: any;
|
|
38
|
+
extractEl: (_: any) => any;
|
|
39
|
+
}) => any;
|
|
40
|
+
}>;
|
|
41
|
+
export default _default;
|
|
42
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
43
|
+
new (): {
|
|
44
|
+
$slots: S;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
@@ -35,17 +35,17 @@
|
|
|
35
35
|
before:transition-all
|
|
36
36
|
before:z-1
|
|
37
37
|
before:duration-500
|
|
38
|
-
`,psuedoHide && `
|
|
38
|
+
`, psuedoHide && `
|
|
39
39
|
after:opacity-0
|
|
40
40
|
before:opacity-0
|
|
41
|
-
`,
|
|
41
|
+
`, $attrs.class)"
|
|
42
42
|
:data-value="progress"
|
|
43
43
|
:title="label"
|
|
44
44
|
role="progressbar"
|
|
45
45
|
:aria-valuenow="clampVal(progress, clamp[0] ?? 0, clamp[1] ?? 100)"
|
|
46
46
|
:aria-valuemin="clamp[0] ?? 0"
|
|
47
47
|
:aria-valuemax="clamp[1] ?? 100"
|
|
48
|
-
v-bind="{...$attrs, class:
|
|
48
|
+
v-bind="{ ...$attrs, class: void 0 }"
|
|
49
49
|
:style="`--progress: ${clampVal(progress, clamp[0] ?? 0, clamp[1] ?? 100)}%;`"
|
|
50
50
|
>
|
|
51
51
|
<div class="procgress-bar--label-wrapper relative flex-1">
|
|
@@ -93,101 +93,75 @@
|
|
|
93
93
|
</div>
|
|
94
94
|
</Transition>
|
|
95
95
|
</template>
|
|
96
|
-
<script setup lang="ts">
|
|
97
|
-
import { type HTMLAttributes,type PropType, ref, watch } from "vue"
|
|
98
|
-
|
|
99
|
-
import { twMerge } from "../../utils/twMerge.js"
|
|
100
|
-
import { type BaseInteractiveProps, baseInteractivePropsDefaults,getFallbackId,type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js"
|
|
101
|
-
|
|
102
|
-
// TODO move to utils
|
|
103
|
-
const clampVal = (n: number, min: number, max: number) => Math.min(Math.max(n, min), max)
|
|
104
96
|
|
|
97
|
+
<script setup>
|
|
98
|
+
import { ref, watch } from "vue";
|
|
99
|
+
import { twMerge } from "../../utils/twMerge.js";
|
|
100
|
+
import { getFallbackId } from "../shared/props.js";
|
|
101
|
+
const clampVal = (n, min, max) => Math.min(Math.max(n, min), max);
|
|
105
102
|
defineOptions({
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
})
|
|
109
|
-
const fallbackId = getFallbackId()
|
|
110
|
-
const props =
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
103
|
+
name: "lib-progress-bar",
|
|
104
|
+
inheritAttrs: false
|
|
105
|
+
});
|
|
106
|
+
const fallbackId = getFallbackId();
|
|
107
|
+
const props = defineProps({
|
|
108
|
+
id: { type: String, required: false },
|
|
109
|
+
disabled: { type: Boolean, required: false, default: false },
|
|
110
|
+
readonly: { type: Boolean, required: false, default: false },
|
|
111
|
+
border: { type: Boolean, required: false, default: true },
|
|
112
|
+
unstyle: { type: Boolean, required: false, default: false },
|
|
113
|
+
label: { type: String, required: false },
|
|
114
|
+
progress: { type: Number, required: true },
|
|
115
|
+
autohideOnComplete: { type: Number, required: false, default: -1 },
|
|
116
|
+
keepSpaceWhenHidden: { type: Boolean, required: false, default: false },
|
|
117
|
+
clamp: { type: Array, required: false, default: () => [0, 100] }
|
|
118
|
+
});
|
|
119
|
+
const hide = ref(false);
|
|
120
|
+
const psuedoHide = ref(false);
|
|
121
|
+
let timeout;
|
|
122
|
+
let type;
|
|
120
123
|
if (props.autohideOnComplete > -1 && (props.progress >= 100 || props.progress < 0)) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
if (props.keepSpaceWhenHidden) {
|
|
125
|
+
hide.value = false;
|
|
126
|
+
psuedoHide.value = true;
|
|
127
|
+
} else {
|
|
128
|
+
hide.value = true;
|
|
129
|
+
psuedoHide.value = false;
|
|
130
|
+
}
|
|
128
131
|
}
|
|
129
|
-
|
|
130
132
|
watch([
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
133
|
+
() => props.progress,
|
|
134
|
+
() => props.keepSpaceWhenHidden,
|
|
135
|
+
() => props.autohideOnComplete
|
|
134
136
|
], () => {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}, { immediate: false })
|
|
161
|
-
|
|
137
|
+
if (props.autohideOnComplete > -1 && (props.progress >= 100 || props.progress < 0)) {
|
|
138
|
+
if (props.keepSpaceWhenHidden) {
|
|
139
|
+
if (type === 1) return;
|
|
140
|
+
clearTimeout(timeout);
|
|
141
|
+
type = 1;
|
|
142
|
+
timeout = setTimeout(() => {
|
|
143
|
+
type = 0;
|
|
144
|
+
hide.value = false;
|
|
145
|
+
psuedoHide.value = true;
|
|
146
|
+
}, props.autohideOnComplete);
|
|
147
|
+
} else {
|
|
148
|
+
if (type === 2) return;
|
|
149
|
+
clearTimeout(timeout);
|
|
150
|
+
type = 2;
|
|
151
|
+
timeout = setTimeout(() => {
|
|
152
|
+
type = 0;
|
|
153
|
+
hide.value = true;
|
|
154
|
+
psuedoHide.value = false;
|
|
155
|
+
}, props.autohideOnComplete);
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
clearTimeout(timeout);
|
|
159
|
+
hide.value = false;
|
|
160
|
+
psuedoHide.value = false;
|
|
161
|
+
}
|
|
162
|
+
}, { immediate: false });
|
|
162
163
|
</script>
|
|
163
|
-
<script lang="ts">
|
|
164
|
-
|
|
165
|
-
type RealProps =
|
|
166
|
-
& LinkableByIdProps
|
|
167
|
-
& BaseInteractiveProps
|
|
168
|
-
& LabelProps
|
|
169
|
-
& {
|
|
170
|
-
progress: number
|
|
171
|
-
/** 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. */
|
|
172
|
-
autohideOnComplete?: number
|
|
173
|
-
/**
|
|
174
|
-
* Do not actually hide the element, just leave an unstyled div,
|
|
175
|
-
* so the whole layout doesn't change on completion when autohideOnComplete is set.
|
|
176
|
-
*/
|
|
177
|
-
keepSpaceWhenHidden?: boolean
|
|
178
|
-
/**
|
|
179
|
-
* By default the progress bar is visually clamped to 0-100, even if the value might be something else.
|
|
180
|
-
* You can change what it's clamped to here, to for example,
|
|
181
|
-
* show at least a small sliver of the progress bar when it's still 0.
|
|
182
|
-
*/
|
|
183
|
-
clamp?: [start:number, end:number]
|
|
184
|
-
}
|
|
185
164
|
|
|
186
|
-
|
|
187
|
-
extends
|
|
188
|
-
/** @vue-ignore */
|
|
189
|
-
Partial<Omit<HTMLAttributes,"class"> & TailwindClassProp>,
|
|
190
|
-
RealProps
|
|
191
|
-
{ }
|
|
165
|
+
<script>
|
|
192
166
|
|
|
193
167
|
</script>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type HTMLAttributes } from "vue";
|
|
2
|
+
import { type BaseInteractiveProps, type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js.js";
|
|
3
|
+
type RealProps = LinkableByIdProps & BaseInteractiveProps & LabelProps & {
|
|
4
|
+
progress: number;
|
|
5
|
+
/** 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. */
|
|
6
|
+
autohideOnComplete?: number;
|
|
7
|
+
/**
|
|
8
|
+
* Do not actually hide the element, just leave an unstyled div,
|
|
9
|
+
* so the whole layout doesn't change on completion when autohideOnComplete is set.
|
|
10
|
+
*/
|
|
11
|
+
keepSpaceWhenHidden?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* By default the progress bar is visually clamped to 0-100, even if the value might be something else.
|
|
14
|
+
* You can change what it's clamped to here, to for example,
|
|
15
|
+
* show at least a small sliver of the progress bar when it's still 0.
|
|
16
|
+
*/
|
|
17
|
+
clamp?: [start: number, end: number];
|
|
18
|
+
};
|
|
19
|
+
interface Props extends
|
|
20
|
+
/** @vue-ignore */
|
|
21
|
+
Partial<Omit<HTMLAttributes, "class"> & TailwindClassProp>, RealProps {
|
|
22
|
+
}
|
|
23
|
+
declare const _default: __VLS_WithSlots<import("vue").DefineComponent<Props, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
24
|
+
disabled: boolean;
|
|
25
|
+
readonly: boolean;
|
|
26
|
+
border: boolean;
|
|
27
|
+
unstyle: boolean;
|
|
28
|
+
autohideOnComplete: number;
|
|
29
|
+
keepSpaceWhenHidden: boolean;
|
|
30
|
+
clamp: [start: number, end: number];
|
|
31
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
32
|
+
default?: (props: {}) => any;
|
|
33
|
+
} & {
|
|
34
|
+
default?: (props: {}) => any;
|
|
35
|
+
}>;
|
|
36
|
+
export default _default;
|
|
37
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
38
|
+
new (): {
|
|
39
|
+
$slots: S;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
contenteditable=false is because of storybook, it's shortcuts interfere when not using real input elements
|
|
5
5
|
-->
|
|
6
6
|
<div
|
|
7
|
-
:id="id?? fallbackId"
|
|
8
|
-
:class="twMerge(
|
|
7
|
+
:id="id ?? fallbackId"
|
|
8
|
+
:class="twMerge(
|
|
9
|
+
`recorder
|
|
9
10
|
flex items-center
|
|
10
11
|
gap-2
|
|
11
12
|
px-2
|
|
@@ -13,37 +14,38 @@
|
|
|
13
14
|
focus-outline-no-offset
|
|
14
15
|
rounded-sm
|
|
15
16
|
`,
|
|
16
|
-
|
|
17
|
+
border && `
|
|
17
18
|
border
|
|
18
19
|
border-neutral-500
|
|
19
20
|
focus:border-accent-500
|
|
20
21
|
`,
|
|
21
|
-
|
|
22
|
-
(disabled || readonly) && `
|
|
22
|
+
(disabled || readonly) && `
|
|
23
23
|
text-neutral-400
|
|
24
24
|
dark:text-neutral-600
|
|
25
25
|
`,
|
|
26
|
-
|
|
26
|
+
(disabled || readonly) && border && `
|
|
27
27
|
bg-neutral-50
|
|
28
28
|
dark:bg-neutral-950
|
|
29
29
|
border-neutral-400
|
|
30
30
|
dark:border-neutral-600
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
`,
|
|
32
|
+
$attrs.class
|
|
33
|
+
)"
|
|
33
34
|
:aria-disabled="disabled"
|
|
34
35
|
:aria-readonly="readonly"
|
|
35
36
|
:tabindex="disabled ? -1 : 0"
|
|
36
37
|
:title="recording ? recordingTitle : tempValue"
|
|
37
38
|
contenteditable="false"
|
|
38
39
|
ref="recorderEl"
|
|
39
|
-
v-bind="{...ariaLabel, ...$attrs, class:
|
|
40
|
+
v-bind="{ ...ariaLabel, ...$attrs, class: void 0 }"
|
|
40
41
|
@blur="handleBlurRecorder($event)"
|
|
41
42
|
@click="handleClickRecorder($event)"
|
|
42
43
|
@keydown.space.prevent="handleClickRecorder($event, true)"
|
|
43
44
|
>
|
|
44
45
|
<!-- :aria-description="recording ? recordingTitle : ''" -->
|
|
45
46
|
<div
|
|
46
|
-
:class="twMerge(
|
|
47
|
+
:class="twMerge(
|
|
48
|
+
`recorder--indicator
|
|
47
49
|
inline-block
|
|
48
50
|
bg-red-700
|
|
49
51
|
rounded-full
|
|
@@ -52,191 +54,139 @@
|
|
|
52
54
|
shrink-0
|
|
53
55
|
hover:bg-red-500
|
|
54
56
|
`,
|
|
55
|
-
|
|
57
|
+
recording && `
|
|
56
58
|
animate-[blink_1s_infinite]
|
|
57
59
|
bg-red-500
|
|
58
60
|
`,
|
|
59
|
-
|
|
61
|
+
(disabled || readonly) && `
|
|
60
62
|
bg-neutral-500
|
|
61
63
|
`
|
|
62
|
-
|
|
64
|
+
)"
|
|
63
65
|
ref="recorderIndicatorEl"
|
|
64
66
|
/>
|
|
65
67
|
<div class="recorder--value before:content-vertical-holder truncate">
|
|
66
|
-
{{ recording
|
|
67
|
-
? recordingValue ?? t("recorder.recording")
|
|
68
|
-
: tempValue }}
|
|
68
|
+
{{ recording ? recordingValue ?? t("recorder.recording") : tempValue }}
|
|
69
69
|
</div>
|
|
70
70
|
</div>
|
|
71
71
|
</template>
|
|
72
|
-
<script setup lang="ts">
|
|
73
|
-
import { keys } from "@alanscodelog/utils/keys.js"
|
|
74
|
-
import { computed, type HTMLAttributes ,onBeforeUnmount, onMounted, type PropType, ref, watch, watchPostEffect } from "vue"
|
|
75
|
-
|
|
76
|
-
import { useAriaLabel } from "../../composables/useAriaLabel.js"
|
|
77
|
-
import { useInjectedI18n } from "../../composables/useInjectedI18n.js"
|
|
78
|
-
import { twMerge } from "../../utils/twMerge.js"
|
|
79
|
-
import { type BaseInteractiveProps, baseInteractivePropsDefaults, getFallbackId, type LabelProps, type LinkableByIdProps,type TailwindClassProp } from "../shared/props.js"
|
|
80
72
|
|
|
73
|
+
<script setup>
|
|
74
|
+
import { keys } from "@alanscodelog/utils/keys";
|
|
75
|
+
import { computed, onBeforeUnmount, onMounted, ref, watch, watchPostEffect } from "vue";
|
|
76
|
+
import { useAriaLabel } from "../../composables/useAriaLabel.js";
|
|
77
|
+
import { useInjectedI18n } from "../../composables/useInjectedI18n.js";
|
|
78
|
+
import { twMerge } from "../../utils/twMerge.js";
|
|
79
|
+
import { getFallbackId } from "../shared/props.js";
|
|
81
80
|
defineOptions({
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
})
|
|
85
|
-
const t = useInjectedI18n()
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const recording = defineModel<boolean>("recording", { required: false, default: false })
|
|
107
|
-
|
|
108
|
-
/** The final value of the recorder. For intermediate values while recording, pass a recorder and set an appropriate recording value. */
|
|
109
|
-
const modelValue = defineModel<string>({ required: true })
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const recorderEl = ref<HTMLInputElement | null>(null)
|
|
113
|
-
const recorderIndicatorEl = ref<HTMLElement | null>(null)
|
|
114
|
-
const canEdit = computed(() => !props.disabled && !props.readonly)
|
|
115
|
-
const tempValue = ref(modelValue.value)
|
|
116
|
-
|
|
81
|
+
name: "lib-recorder",
|
|
82
|
+
inheritAttrs: false
|
|
83
|
+
});
|
|
84
|
+
const t = useInjectedI18n();
|
|
85
|
+
const emits = defineEmits(["recorder:blur", "recorder:click", "focus:parent"]);
|
|
86
|
+
const fallbackId = getFallbackId();
|
|
87
|
+
const props = defineProps({
|
|
88
|
+
id: { type: String, required: false, default: void 0 },
|
|
89
|
+
disabled: { type: Boolean, required: false, default: false },
|
|
90
|
+
readonly: { type: Boolean, required: false, default: false },
|
|
91
|
+
border: { type: Boolean, required: false, default: true },
|
|
92
|
+
unstyle: { type: Boolean, required: false, default: false },
|
|
93
|
+
label: { type: String, required: false },
|
|
94
|
+
recordingValue: { type: String, required: false },
|
|
95
|
+
recordingTitle: { type: String, required: false, default: "" },
|
|
96
|
+
recorder: { type: null, required: false, default: void 0 },
|
|
97
|
+
binders: { type: null, required: false, default: void 0 }
|
|
98
|
+
});
|
|
99
|
+
const recording = defineModel("recording", { type: Boolean, ...{ required: false, default: false } });
|
|
100
|
+
const modelValue = defineModel({ type: String, ...{ required: true } });
|
|
101
|
+
const recorderEl = ref(null);
|
|
102
|
+
const recorderIndicatorEl = ref(null);
|
|
103
|
+
const canEdit = computed(() => !props.disabled && !props.readonly);
|
|
104
|
+
const tempValue = ref(modelValue.value);
|
|
117
105
|
watch([() => props.binders, () => props.binders], () => {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
})
|
|
122
|
-
|
|
106
|
+
if (recording.value) {
|
|
107
|
+
throw new Error("Component was not designed to allow swapping out of binders/recorders while recording");
|
|
108
|
+
}
|
|
109
|
+
});
|
|
123
110
|
watch(modelValue, () => {
|
|
124
|
-
|
|
125
|
-
})
|
|
126
|
-
const ariaLabel = useAriaLabel(props)
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
111
|
+
tempValue.value = modelValue.value;
|
|
112
|
+
});
|
|
113
|
+
const ariaLabel = useAriaLabel(props);
|
|
114
|
+
const boundListeners = {};
|
|
115
|
+
let isBound = false;
|
|
116
|
+
const unbindListeners = () => {
|
|
117
|
+
if (!isBound) return;
|
|
118
|
+
isBound = false;
|
|
119
|
+
if (props.recorder) {
|
|
120
|
+
for (const key of keys(boundListeners)) {
|
|
121
|
+
recorderEl.value?.removeEventListener(key, boundListeners[key]);
|
|
122
|
+
delete boundListeners[key];
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (props.binders && recorderEl.value) {
|
|
126
|
+
props.binders.unbind(recorderEl.value);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const bindListeners = () => {
|
|
130
|
+
if (!props.recorder && !props.binders) {
|
|
131
|
+
throw new Error("Record is true but no recorder or binders props was passed");
|
|
132
|
+
}
|
|
133
|
+
if (props.recorder && props.binders) {
|
|
134
|
+
throw new Error("Recording is true and was passed both a recorder and a binders prop. Both cannot be used at the same time.");
|
|
135
|
+
}
|
|
136
|
+
isBound = true;
|
|
137
|
+
if (props.recorder) {
|
|
138
|
+
for (const key of keys(props.recorder)) {
|
|
139
|
+
recorderEl.value?.addEventListener(key, props.recorder[key], { passive: false });
|
|
140
|
+
boundListeners[key] = props.recorder[key];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (props.binders && recorderEl.value) {
|
|
144
|
+
props.binders.bind(recorderEl.value);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
163
147
|
watchPostEffect(() => {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
})
|
|
181
|
-
|
|
148
|
+
if (!canEdit.value) {
|
|
149
|
+
unbindListeners();
|
|
150
|
+
recording.value = false;
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (recording.value) {
|
|
154
|
+
bindListeners();
|
|
155
|
+
} else {
|
|
156
|
+
if ((props.recorder || props.binders) && isBound) {
|
|
157
|
+
unbindListeners();
|
|
158
|
+
emits("focus:parent");
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
});
|
|
182
162
|
onBeforeUnmount(() => {
|
|
183
|
-
|
|
184
|
-
})
|
|
163
|
+
unbindListeners();
|
|
164
|
+
});
|
|
185
165
|
onMounted(() => {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
})
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
|
|
166
|
+
if (recording.value) {
|
|
167
|
+
bindListeners();
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
const handleBlurRecorder = (e) => {
|
|
171
|
+
if (!canEdit.value) return;
|
|
172
|
+
if (props.recorder || props.binders) {
|
|
173
|
+
emits("recorder:blur", e);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
const handleClickRecorder = (e, isSpaceKey = false) => {
|
|
177
|
+
if (!canEdit.value) return;
|
|
178
|
+
if (!recording.value) {
|
|
179
|
+
recorderEl.value?.focus();
|
|
180
|
+
}
|
|
181
|
+
if (props.recorder || props.binders) {
|
|
182
|
+
if (isSpaceKey) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
emits("recorder:click", { event: e, indicator: recorderIndicatorEl.value, input: recorderEl.value });
|
|
186
|
+
}
|
|
187
|
+
};
|
|
210
188
|
</script>
|
|
211
|
-
<script lang="ts">
|
|
212
|
-
type RealProps =
|
|
213
|
-
& LinkableByIdProps
|
|
214
|
-
& BaseInteractiveProps
|
|
215
|
-
& LabelProps
|
|
216
|
-
& {
|
|
217
|
-
border?: boolean
|
|
218
|
-
/** A value to display while recording, if none given the i18n `recorder.recording` key is used. */
|
|
219
|
-
recordingValue?: string
|
|
220
|
-
/** A title to display on the input div while recording. Is also used as the aria-description. */
|
|
221
|
-
recordingTitle?: string
|
|
222
|
-
/**
|
|
223
|
-
* The recorder object is a series of event listeners to attach to the input div while recording is started. If you need to bind directly to the element, see the `binders` prop.
|
|
224
|
-
*
|
|
225
|
-
* The listeners are then unbound when recording is set to false again.
|
|
226
|
-
*
|
|
227
|
-
* Note that the component does not handle the setting of `recording` (unless the component is disabled), `modelValue`, or `recordingValue` at all and has no mechanism for cancelling a recording. It is left to the recorder listeners and any `recorder:*` handlers to determine what to do.
|
|
228
|
-
*/
|
|
229
|
-
recorder?: undefined | Record<string, any>
|
|
230
|
-
/** This provides a way to manually attach/remove event listeners to/from the element. It is an alternative to the `recorder` prop, see it for more details. Both cannot be specified at the same time.*/
|
|
231
|
-
binders?: undefined | { bind: (el: HTMLElement) => void, unbind: (el: HTMLElement) => void }
|
|
232
|
-
/** The id of the element. If not provided, the id will be generated automatically. */
|
|
233
|
-
id?: string
|
|
234
|
-
}
|
|
235
189
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
/** @vue-ignore */
|
|
239
|
-
Partial<Omit<HTMLAttributes,"class"> & TailwindClassProp>,
|
|
240
|
-
RealProps
|
|
241
|
-
{ }
|
|
190
|
+
<script>
|
|
191
|
+
|
|
242
192
|
</script>
|