@witchcraft/ui 0.1.0 → 0.1.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 +2 -2
- package/dist/module.mjs +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 -31
- package/dist/runtime/components/Icon/Icon.vue.d.ts +21 -0
- package/dist/runtime/components/LibButton/LibButton.vue +58 -77
- package/dist/runtime/components/LibButton/LibButton.vue.d.ts +36 -0
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +48 -75
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +42 -0
- package/dist/runtime/components/LibColorInput/LibColorInput.vue +63 -108
- package/dist/runtime/components/LibColorInput/LibColorInput.vue.d.ts +63 -0
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +271 -352
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue.d.ts +61 -0
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +32 -57
- 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 +53 -82
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue.d.ts +34 -0
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +50 -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 +42 -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 +113 -157
- package/dist/runtime/components/LibFileInput/LibFileInput.vue.d.ts +43 -0
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +215 -242
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue.d.ts +165 -0
- package/dist/runtime/components/LibLabel/LibLabel.vue +30 -46
- package/dist/runtime/components/LibLabel/LibLabel.vue.d.ts +27 -0
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +44 -59
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue.d.ts +29 -0
- package/dist/runtime/components/LibNotifications/LibNotification.vue +32 -49
- package/dist/runtime/components/LibNotifications/LibNotification.vue.d.ts +17 -0
- package/dist/runtime/components/LibNotifications/LibNotifications.vue +63 -84
- package/dist/runtime/components/LibNotifications/LibNotifications.vue.d.ts +13 -0
- package/dist/runtime/components/LibPagination/LibPagination.vue +67 -112
- package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +104 -0
- package/dist/runtime/components/LibPalette/LibPalette.vue +20 -23
- package/dist/runtime/components/LibPalette/LibPalette.vue.d.ts +14 -0
- package/dist/runtime/components/LibPopup/LibPopup.vue +314 -352
- package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +46 -0
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +70 -92
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue.d.ts +41 -0
- package/dist/runtime/components/LibRecorder/LibRecorder.vue +133 -178
- package/dist/runtime/components/LibRecorder/LibRecorder.vue.d.ts +77 -0
- package/dist/runtime/components/LibRoot/LibRoot.vue +73 -100
- package/dist/runtime/components/LibRoot/LibRoot.vue.d.ts +41 -0
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue +49 -78
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue.d.ts +35 -0
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +123 -157
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +94 -0
- package/dist/runtime/components/LibTable/LibTable.vue +63 -100
- 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/directives/vResizableCols.js +89 -83
- package/dist/types.d.mts +2 -6
- package/package.json +11 -11
- package/src/runtime/components/Focus.stories.ts +3 -2
- package/src/runtime/components/Icon/Icon.vue +0 -1
- package/src/runtime/components/LibButton/LibButton.vue +0 -1
- package/src/runtime/components/LibCheckbox/LibCheckbox.vue +0 -1
- package/src/runtime/components/LibColorInput/LibColorInput.vue +0 -1
- package/src/runtime/components/LibColorPicker/utils/safeConvertToHsva.ts +0 -1
- package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +0 -1
- package/src/runtime/components/LibFileInput/LibFileInput.vue +0 -1
- package/src/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +0 -1
- package/src/runtime/components/LibMultiValues/LibMultiValues.vue +0 -1
- package/src/runtime/components/LibNotifications/LibNotification.vue +0 -1
- package/src/runtime/components/LibNotifications/LibNotifications.vue +0 -1
- package/src/runtime/components/LibPagination/LibPagination.vue +0 -1
- package/src/runtime/components/LibPopup/LibPopup.vue +0 -1
- package/src/runtime/components/LibProgressBar/LibProgressBar.vue +0 -1
- package/src/runtime/components/LibRecorder/LibRecorder.vue +0 -1
- package/src/runtime/components/LibSimpleInput/LibSimpleInput.vue +0 -1
- package/src/runtime/components/LibSuggestions/LibSuggestions.vue +0 -1
- package/src/runtime/components/LibTable/LibTable.vue +0 -1
- package/src/runtime/directives/vResizableCols.ts +79 -73
- 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,77 @@
|
|
|
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
|
+
border?: boolean;
|
|
5
|
+
/** A value to display while recording, if none given the i18n `recorder.recording` key is used. */
|
|
6
|
+
recordingValue?: string;
|
|
7
|
+
/** A title to display on the input div while recording. Is also used as the aria-description. */
|
|
8
|
+
recordingTitle?: string;
|
|
9
|
+
/**
|
|
10
|
+
* 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.
|
|
11
|
+
*
|
|
12
|
+
* The listeners are then unbound when recording is set to false again.
|
|
13
|
+
*
|
|
14
|
+
* 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.
|
|
15
|
+
*/
|
|
16
|
+
recorder?: undefined | Record<string, any>;
|
|
17
|
+
/** 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.*/
|
|
18
|
+
binders?: undefined | {
|
|
19
|
+
bind: (el: HTMLElement) => void;
|
|
20
|
+
unbind: (el: HTMLElement) => void;
|
|
21
|
+
};
|
|
22
|
+
/** The id of the element. If not provided, the id will be generated automatically. */
|
|
23
|
+
id?: string;
|
|
24
|
+
};
|
|
25
|
+
interface Props extends
|
|
26
|
+
/** @vue-ignore */
|
|
27
|
+
Partial<Omit<HTMLAttributes, "class"> & TailwindClassProp>, RealProps {
|
|
28
|
+
}
|
|
29
|
+
declare const _default: import("vue").DefineComponent<Props & {
|
|
30
|
+
/**
|
|
31
|
+
* Puts the element into recording mode if true. See {@link props.recorder}.
|
|
32
|
+
*/
|
|
33
|
+
recording?: boolean;
|
|
34
|
+
/** The final value of the recorder. For intermediate values while recording, pass a recorder and set an appropriate recording value. */
|
|
35
|
+
modelValue: string;
|
|
36
|
+
}, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
37
|
+
"update:modelValue": (value: string) => any;
|
|
38
|
+
"update:recording": (value: boolean) => any;
|
|
39
|
+
} & {
|
|
40
|
+
"recorder:blur": ($event: FocusEvent) => any;
|
|
41
|
+
"recorder:click": (args_0: {
|
|
42
|
+
event: MouseEvent | KeyboardEvent;
|
|
43
|
+
indicator: HTMLElement;
|
|
44
|
+
input: HTMLInputElement;
|
|
45
|
+
}) => any;
|
|
46
|
+
"focus:parent": () => any;
|
|
47
|
+
}, string, import("vue").PublicProps, Readonly<Props & {
|
|
48
|
+
/**
|
|
49
|
+
* Puts the element into recording mode if true. See {@link props.recorder}.
|
|
50
|
+
*/
|
|
51
|
+
recording?: boolean;
|
|
52
|
+
/** The final value of the recorder. For intermediate values while recording, pass a recorder and set an appropriate recording value. */
|
|
53
|
+
modelValue: string;
|
|
54
|
+
}> & Readonly<{
|
|
55
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
56
|
+
"onUpdate:recording"?: ((value: boolean) => any) | undefined;
|
|
57
|
+
"onRecorder:blur"?: (($event: FocusEvent) => any) | undefined;
|
|
58
|
+
"onRecorder:click"?: ((args_0: {
|
|
59
|
+
event: MouseEvent | KeyboardEvent;
|
|
60
|
+
indicator: HTMLElement;
|
|
61
|
+
input: HTMLInputElement;
|
|
62
|
+
}) => any) | undefined;
|
|
63
|
+
"onFocus:parent"?: (() => any) | undefined;
|
|
64
|
+
}>, {
|
|
65
|
+
id: string;
|
|
66
|
+
disabled: boolean;
|
|
67
|
+
readonly: boolean;
|
|
68
|
+
border: boolean;
|
|
69
|
+
unstyle: boolean;
|
|
70
|
+
recordingTitle: string;
|
|
71
|
+
recorder: Record<string, any>;
|
|
72
|
+
binders: {
|
|
73
|
+
bind: (el: HTMLElement) => void;
|
|
74
|
+
unbind: (el: HTMLElement) => void;
|
|
75
|
+
};
|
|
76
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
77
|
+
export default _default;
|
|
@@ -2,34 +2,36 @@
|
|
|
2
2
|
<div :id="id"
|
|
3
3
|
tabindex="-1"
|
|
4
4
|
:class="twMerge(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
v-bind="{
|
|
5
|
+
showOutline ? 'group outlined outlined-visible' : '[&_*]:outline-hidden',
|
|
6
|
+
darkMode && ' dark',
|
|
7
|
+
$attrs['wrapperAttrs']?.class
|
|
8
|
+
)"
|
|
9
|
+
v-bind="{ ...$attrs['wrapperAttrs'], attrs: void 0, class: void 0 }"
|
|
10
10
|
:ref="handleRef"
|
|
11
11
|
>
|
|
12
12
|
<!-- id root is useful for teleports, so they are at the topmost level where they can still be styled -->
|
|
13
13
|
<!-- See TestControls for why the margins here -->
|
|
14
14
|
<div
|
|
15
15
|
id="root"
|
|
16
|
-
v-bind="{ ...$attrs.attrs, class:
|
|
17
|
-
:class="twMerge(
|
|
16
|
+
v-bind="{ ...$attrs.attrs, class: void 0, wrapperAttrs: void 0 }"
|
|
17
|
+
:class="twMerge(
|
|
18
|
+
`
|
|
18
19
|
dark:bg-fg
|
|
19
20
|
dark:text-bg
|
|
20
21
|
bg-bg
|
|
21
22
|
text-fg
|
|
22
23
|
`,
|
|
23
|
-
|
|
24
|
+
testWrapperMode && `
|
|
24
25
|
px-10
|
|
25
26
|
pb-10
|
|
26
27
|
`,
|
|
27
|
-
|
|
28
|
+
!testWrapperMode && `
|
|
28
29
|
min-h-dvh
|
|
29
30
|
flex
|
|
30
31
|
flex-col
|
|
31
32
|
`,
|
|
32
|
-
|
|
33
|
+
$attrs.attrs?.class
|
|
34
|
+
)"
|
|
33
35
|
>
|
|
34
36
|
<TestControls v-if="testWrapperMode" :show-outline="showOutline"/>
|
|
35
37
|
<Notifications v-if="useNotifications && isClientSide"/>
|
|
@@ -38,102 +40,73 @@
|
|
|
38
40
|
</div>
|
|
39
41
|
</template>
|
|
40
42
|
|
|
41
|
-
<script setup
|
|
42
|
-
import { unreachable } from "@alanscodelog/utils/unreachable.js"
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import
|
|
56
|
-
import
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
theme: undefined,
|
|
77
|
-
testWrapperMode: false,
|
|
78
|
-
outline: true,
|
|
79
|
-
forceOutline: false,
|
|
80
|
-
id: "app",
|
|
81
|
-
getRef: undefined,
|
|
82
|
-
isClientSide: true,
|
|
83
|
-
useBuiltinTranslations: true,
|
|
84
|
-
useNotifications: true,
|
|
85
|
-
notificationHandler: undefined
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
const el = ref<HTMLElement | null>(null)
|
|
89
|
-
|
|
90
|
-
function handleRef(_: Element | ComponentPublicInstance | null): void {
|
|
91
|
-
if (_ !== null && !(_ instanceof HTMLElement)) unreachable()
|
|
92
|
-
el.value = _
|
|
93
|
-
props.getRef?.(_)
|
|
43
|
+
<script setup>
|
|
44
|
+
import { unreachable } from "@alanscodelog/utils/unreachable.js";
|
|
45
|
+
import {} from "metamorphosis";
|
|
46
|
+
import { computed, onBeforeUnmount, onMounted, ref, toRaw } from "vue";
|
|
47
|
+
import { useAccesibilityOutline } from "../../composables/useAccesibilityOutline.js";
|
|
48
|
+
import { useDivideAttrs } from "../../composables/useDivideAttrs.js";
|
|
49
|
+
import { useNotificationHandler } from "../../composables/useNotificationHandler.js";
|
|
50
|
+
import { useSetupDarkMode } from "../../composables/useSetupDarkMode.js";
|
|
51
|
+
import { useSetupI18n } from "../../composables/useSetupI18n.js";
|
|
52
|
+
import { useSetupLocale } from "../../composables/useSetupLocale.js";
|
|
53
|
+
import { useShowDevOnlyKey } from "../../composables/useShowDevOnlyKey.js";
|
|
54
|
+
import { NotificationHandler } from "../../helpers/NotificationHandler.js";
|
|
55
|
+
import { theme as defaultTheme } from "../../theme.js";
|
|
56
|
+
import { twMerge } from "../../utils/twMerge.js";
|
|
57
|
+
import Notifications from "../LibNotifications/LibNotifications.vue";
|
|
58
|
+
import TestControls from "../TestControls/TestControls.vue";
|
|
59
|
+
const $attrs = useDivideAttrs(["wrapper"]);
|
|
60
|
+
defineOptions({ name: "root", inheritAttrs: false, suspensible: false });
|
|
61
|
+
const props = defineProps({
|
|
62
|
+
theme: { type: Object, required: false, default: void 0 },
|
|
63
|
+
outline: { type: Boolean, required: false, default: true },
|
|
64
|
+
forceOutline: { type: Boolean, required: false, default: false },
|
|
65
|
+
testWrapperMode: { type: Boolean, required: false, default: false },
|
|
66
|
+
id: { type: String, required: false, default: "app" },
|
|
67
|
+
getRef: { type: Function, required: false, default: void 0 },
|
|
68
|
+
isClientSide: { type: Boolean, required: false, default: true },
|
|
69
|
+
useBuiltinTranslations: { type: Boolean, required: false, default: true },
|
|
70
|
+
useNotifications: { type: Boolean, required: false, default: true },
|
|
71
|
+
notificationHandler: { type: Object, required: false, default: void 0 }
|
|
72
|
+
});
|
|
73
|
+
const el = ref(null);
|
|
74
|
+
function handleRef(_) {
|
|
75
|
+
if (_ !== null && !(_ instanceof HTMLElement)) unreachable();
|
|
76
|
+
el.value = _;
|
|
77
|
+
props.getRef?.(_);
|
|
94
78
|
}
|
|
95
|
-
|
|
96
79
|
if (props.useNotifications) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const autoOutline = useAccesibilityOutline(el).outline
|
|
102
|
-
|
|
103
|
-
const showOutline = computed(() => (props.outline && autoOutline.value) || props.forceOutline)
|
|
104
|
-
|
|
105
|
-
const theme = computed(() => props.theme ?? defaultTheme)
|
|
106
|
-
const themeCb = (): void => {
|
|
107
|
-
toRaw(theme.value).attach(el.value!)
|
|
80
|
+
const handler = props.notificationHandler ?? new NotificationHandler();
|
|
81
|
+
useNotificationHandler(handler, props.isClientSide);
|
|
108
82
|
}
|
|
83
|
+
const autoOutline = useAccesibilityOutline(el).outline;
|
|
84
|
+
const showOutline = computed(() => props.outline && autoOutline.value || props.forceOutline);
|
|
85
|
+
const theme = computed(() => props.theme ?? defaultTheme);
|
|
86
|
+
const themeCb = () => {
|
|
87
|
+
toRaw(theme.value).attach(el.value);
|
|
88
|
+
};
|
|
109
89
|
if (props.isClientSide) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
90
|
+
onMounted(() => {
|
|
91
|
+
toRaw(theme.value).on("change", themeCb);
|
|
92
|
+
themeCb();
|
|
93
|
+
});
|
|
94
|
+
onBeforeUnmount(() => {
|
|
95
|
+
toRaw(theme.value).off("change", themeCb);
|
|
96
|
+
});
|
|
117
97
|
}
|
|
118
|
-
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
const darkMode = darkModeSetup.darkMode
|
|
122
|
-
|
|
123
|
-
useShowDevOnlyKey()
|
|
124
|
-
|
|
98
|
+
const darkModeSetup = useSetupDarkMode({ isClientSide: props.isClientSide });
|
|
99
|
+
const darkMode = darkModeSetup.darkMode;
|
|
100
|
+
useShowDevOnlyKey();
|
|
125
101
|
defineExpose({
|
|
126
|
-
|
|
127
|
-
})
|
|
128
|
-
|
|
102
|
+
darkMode: darkModeSetup
|
|
103
|
+
});
|
|
129
104
|
if (props.useBuiltinTranslations) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
105
|
+
const { languageLocale } = useSetupLocale();
|
|
106
|
+
void useSetupI18n({
|
|
107
|
+
locale: languageLocale,
|
|
108
|
+
useBuiltinTranslations: true,
|
|
109
|
+
useDummyMessageSetWhileLoading: true
|
|
110
|
+
});
|
|
136
111
|
}
|
|
137
|
-
|
|
138
112
|
</script>
|
|
139
|
-
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type Theme } from "metamorphosis";
|
|
2
|
+
import { NotificationHandler } from "../../helpers/NotificationHandler.js.js";
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
theme?: Theme;
|
|
5
|
+
outline?: boolean;
|
|
6
|
+
forceOutline?: boolean;
|
|
7
|
+
testWrapperMode?: boolean;
|
|
8
|
+
id?: string;
|
|
9
|
+
/** You can set a ref to the root element by passing :getRef="_ => el = _" */
|
|
10
|
+
getRef?: (el: HTMLElement | null) => void;
|
|
11
|
+
/** True by default, should be passed import.meta.client if using nuxt, or false when running server side. */
|
|
12
|
+
isClientSide?: boolean;
|
|
13
|
+
useBuiltinTranslations?: boolean;
|
|
14
|
+
useNotifications?: boolean;
|
|
15
|
+
notificationHandler?: NotificationHandler;
|
|
16
|
+
};
|
|
17
|
+
declare var __VLS_9: {};
|
|
18
|
+
type __VLS_Slots = {} & {
|
|
19
|
+
default?: (props: typeof __VLS_9) => any;
|
|
20
|
+
};
|
|
21
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {
|
|
22
|
+
darkMode: import("../../composables/useDarkMode.js.js").DarkModeState & import("../../composables/useDarkMode.js.js").DarkModeCommands;
|
|
23
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
24
|
+
theme: Theme;
|
|
25
|
+
id: string;
|
|
26
|
+
useBuiltinTranslations: boolean;
|
|
27
|
+
isClientSide: boolean;
|
|
28
|
+
outline: boolean;
|
|
29
|
+
forceOutline: boolean;
|
|
30
|
+
testWrapperMode: boolean;
|
|
31
|
+
getRef: (el: HTMLElement | null) => void;
|
|
32
|
+
useNotifications: boolean;
|
|
33
|
+
notificationHandler: NotificationHandler;
|
|
34
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
35
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
36
|
+
export default _default;
|
|
37
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
38
|
+
new (): {
|
|
39
|
+
$slots: S;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<input
|
|
3
3
|
:id="id ?? fallbackId"
|
|
4
|
-
:class="twMerge(
|
|
4
|
+
:class="twMerge(
|
|
5
|
+
`
|
|
5
6
|
simple-input
|
|
6
7
|
flex-1
|
|
7
8
|
grow-[999999]
|
|
@@ -27,24 +28,24 @@
|
|
|
27
28
|
dark:disabled:bg-neutral-950
|
|
28
29
|
dark:disabled:text-neutral-500
|
|
29
30
|
`,
|
|
30
|
-
|
|
31
|
+
type === `text` && `
|
|
31
32
|
min-w-[10ch]
|
|
32
33
|
w-full
|
|
33
34
|
`,
|
|
34
|
-
|
|
35
|
+
type === `number` && `
|
|
35
36
|
w-12
|
|
36
37
|
placeholder:text-transparent
|
|
37
38
|
appearance-none
|
|
38
39
|
pr-0
|
|
39
40
|
`,
|
|
40
|
-
|
|
41
|
+
border && `
|
|
41
42
|
border
|
|
42
43
|
border-neutral-500
|
|
43
44
|
focus:border-accent-500
|
|
44
45
|
disabled:border-neutral-400
|
|
45
46
|
dark:disabled:border-neutral-600
|
|
46
47
|
`,
|
|
47
|
-
|
|
48
|
+
!valid && `
|
|
48
49
|
placeholder:text-danger-700
|
|
49
50
|
border-danger-700
|
|
50
51
|
focus:border-danger-700
|
|
@@ -54,8 +55,8 @@
|
|
|
54
55
|
dark:placeholder:text-danger-700
|
|
55
56
|
dark:border-danger-600
|
|
56
57
|
`,
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
$attrs?.class
|
|
59
|
+
)"
|
|
59
60
|
:data-border="border"
|
|
60
61
|
:data-invalid="!valid"
|
|
61
62
|
:type="type"
|
|
@@ -63,84 +64,54 @@
|
|
|
63
64
|
:disabled="disabled"
|
|
64
65
|
:readonly="readonly"
|
|
65
66
|
v-model="modelValue"
|
|
66
|
-
v-bind="{...$attrs, class:
|
|
67
|
+
v-bind="{ ...$attrs, class: void 0, ...ariaLabel }"
|
|
67
68
|
@keydown="handleKeydown"
|
|
68
|
-
@input="emit('input', $event
|
|
69
|
+
@input="emit('input', $event)"
|
|
69
70
|
>
|
|
70
71
|
</template>
|
|
71
72
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
import {
|
|
75
|
-
|
|
76
|
-
import {
|
|
77
|
-
import {
|
|
78
|
-
import {
|
|
79
|
-
import { twMerge } from "../../utils/twMerge.js"
|
|
80
|
-
import { type BaseInteractiveProps, baseInteractivePropsDefaults, getFallbackId,type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js"
|
|
81
|
-
|
|
82
|
-
|
|
73
|
+
<script setup>
|
|
74
|
+
import { useAttrs } from "vue";
|
|
75
|
+
import { useAriaLabel } from "../../composables/useAriaLabel.js";
|
|
76
|
+
import { usePreHydrationValue } from "../../composables/usePreHydrationValue.js";
|
|
77
|
+
import { hasModifiers } from "../../helpers/hasModifiers.js";
|
|
78
|
+
import { twMerge } from "../../utils/twMerge.js";
|
|
79
|
+
import { baseInteractivePropsDefaults, getFallbackId } from "../shared/props.js";
|
|
83
80
|
defineOptions({
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
function handleKeydown(e
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
81
|
+
name: "lib-simple-input",
|
|
82
|
+
inheritAttrs: false
|
|
83
|
+
});
|
|
84
|
+
const fallbackId = getFallbackId();
|
|
85
|
+
const props = defineProps(/* @__PURE__ */ _mergeDefaults({
|
|
86
|
+
id: { type: String, required: false },
|
|
87
|
+
label: { type: String, required: false },
|
|
88
|
+
disabled: { type: Boolean, required: false },
|
|
89
|
+
readonly: { type: Boolean, required: false },
|
|
90
|
+
border: { type: Boolean, required: false },
|
|
91
|
+
unstyle: { type: Boolean, required: false },
|
|
92
|
+
placeholder: { type: null, required: false },
|
|
93
|
+
type: { type: null, required: false },
|
|
94
|
+
valid: { type: Boolean, required: false }
|
|
95
|
+
}, {
|
|
96
|
+
id: "",
|
|
97
|
+
placeholder: "",
|
|
98
|
+
valid: true,
|
|
99
|
+
label: "",
|
|
100
|
+
type: void 0,
|
|
101
|
+
...baseInteractivePropsDefaults
|
|
102
|
+
}));
|
|
103
|
+
const modelValue = defineModel({ type: null, ...{ required: true } });
|
|
104
|
+
const emit = defineEmits(["submit", "input"]);
|
|
105
|
+
const $attrs = useAttrs();
|
|
106
|
+
const ariaLabel = useAriaLabel(props, fallbackId);
|
|
107
|
+
function handleKeydown(e) {
|
|
108
|
+
if (e.key === "Enter" && !hasModifiers(e)) {
|
|
109
|
+
emit("submit", modelValue.value);
|
|
110
|
+
}
|
|
114
111
|
}
|
|
115
|
-
usePreHydrationValue(props.id ?? fallbackId, modelValue)
|
|
116
|
-
|
|
112
|
+
usePreHydrationValue(props.id ?? fallbackId, modelValue);
|
|
117
113
|
</script>
|
|
118
114
|
|
|
119
|
-
<script
|
|
120
|
-
|
|
121
|
-
type RealProps =
|
|
122
|
-
& LinkableByIdProps
|
|
123
|
-
& LabelProps
|
|
124
|
-
& BaseInteractiveProps
|
|
125
|
-
& {
|
|
126
|
-
placeholder?: InputHTMLAttributes["placeholder"]
|
|
127
|
-
disabled?: InputHTMLAttributes["disabled"]
|
|
128
|
-
id?: InputHTMLAttributes["id"]
|
|
129
|
-
type?: InputHTMLAttributes["type"]
|
|
130
|
-
valid?: boolean
|
|
131
|
-
}
|
|
115
|
+
<script>
|
|
132
116
|
|
|
133
|
-
interface Props
|
|
134
|
-
extends
|
|
135
|
-
/** @vue-ignore */
|
|
136
|
-
Partial<Omit<
|
|
137
|
-
InputHTMLAttributes,
|
|
138
|
-
| "class"
|
|
139
|
-
| "readonly"
|
|
140
|
-
| "disabled"
|
|
141
|
-
| "onSubmit"
|
|
142
|
-
| "onInput"
|
|
143
|
-
> & TailwindClassProp>,
|
|
144
|
-
RealProps
|
|
145
|
-
{}
|
|
146
117
|
</script>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type InputHTMLAttributes } from "vue";
|
|
2
|
+
import { type BaseInteractiveProps, type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js.js";
|
|
3
|
+
type RealProps = LinkableByIdProps & LabelProps & BaseInteractiveProps & {
|
|
4
|
+
placeholder?: InputHTMLAttributes["placeholder"];
|
|
5
|
+
disabled?: InputHTMLAttributes["disabled"];
|
|
6
|
+
id?: InputHTMLAttributes["id"];
|
|
7
|
+
type?: InputHTMLAttributes["type"];
|
|
8
|
+
valid?: boolean;
|
|
9
|
+
};
|
|
10
|
+
interface Props extends
|
|
11
|
+
/** @vue-ignore */
|
|
12
|
+
Partial<Omit<InputHTMLAttributes, "class" | "readonly" | "disabled" | "onSubmit" | "onInput"> & TailwindClassProp>, RealProps {
|
|
13
|
+
}
|
|
14
|
+
declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
15
|
+
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
|
|
16
|
+
readonly onInput?: ((val: InputEvent) => any) | undefined;
|
|
17
|
+
readonly onSubmit?: ((val: T) => any) | undefined;
|
|
18
|
+
readonly "onUpdate:modelValue"?: ((value: T) => any) | undefined;
|
|
19
|
+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, "onInput" | "onSubmit" | "onUpdate:modelValue"> & (Props & {
|
|
20
|
+
modelValue: T;
|
|
21
|
+
}) & Partial<{}>> & import("vue").PublicProps;
|
|
22
|
+
expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
|
|
23
|
+
attrs: any;
|
|
24
|
+
slots: {};
|
|
25
|
+
emit: {
|
|
26
|
+
(e: "submit", val: T): void;
|
|
27
|
+
(e: "input", val: InputEvent): void;
|
|
28
|
+
} & ((evt: "update:modelValue", value: T) => void);
|
|
29
|
+
}>) => import("vue").VNode & {
|
|
30
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
31
|
+
};
|
|
32
|
+
export default _default;
|
|
33
|
+
type __VLS_PrettifyLocal<T> = {
|
|
34
|
+
[K in keyof T as K]: T[K];
|
|
35
|
+
} & {};
|