vueless 0.0.478-beta.3 → 0.0.479
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/composables/useBreakpoint.js +1 -1
- package/composables/useUI.js +1 -204
- package/constants.js +1 -2
- package/directives/clickOutside/vClickOutside.js +2 -2
- package/directives/tooltip/storybook/stories.js +5 -5
- package/{index.ts → index.js} +7 -10
- package/package.json +18 -28
- package/preset.tailwind.js +7 -16
- package/ui.button/config.js +0 -12
- package/ui.button/storybook/stories.js +2 -2
- package/ui.button-link/ULink.vue +1 -1
- package/ui.button-link/config.js +0 -9
- package/ui.button-link/storybook/stories.js +1 -1
- package/ui.button-toggle/storybook/stories.js +1 -1
- package/ui.container-divider/storybook/stories.js +1 -1
- package/ui.container-modal/storybook/stories.js +1 -1
- package/ui.container-modal-confirm/storybook/stories.js +1 -1
- package/ui.container-row/storybook/stories.js +1 -1
- package/ui.data-list/UDataList.vue +4 -4
- package/ui.data-table/UTable.vue +1 -1
- package/ui.dropdown-badge/config.js +0 -1
- package/ui.dropdown-badge/storybook/stories.js +1 -1
- package/ui.dropdown-button/config.js +0 -1
- package/ui.dropdown-button/storybook/stories.js +2 -2
- package/ui.dropdown-link/storybook/stories.js +1 -1
- package/ui.dropdown-list/storybook/stories.js +1 -1
- package/ui.form-checkbox/config.js +0 -9
- package/ui.form-checkbox/storybook/stories.js +1 -1
- package/ui.form-checkbox-group/storybook/stories.js +1 -1
- package/ui.form-checkbox-multi-state/storybook/stories.js +1 -1
- package/ui.form-color-picker/config.js +0 -7
- package/ui.form-color-picker/storybook/stories.js +1 -1
- package/ui.form-date-picker/storybook/stories.js +2 -2
- package/ui.form-date-picker-range/storybook/stories.js +1 -1
- package/ui.form-input/UInput.vue +1 -1
- package/ui.form-input/storybook/stories.js +1 -1
- package/ui.form-input-file/storybook/stories.js +1 -1
- package/ui.form-input-money/storybook/stories.js +1 -1
- package/ui.form-input-money/useFormatCurrency.js +1 -1
- package/ui.form-input-number/UInputNumber.vue +3 -4
- package/ui.form-input-number/storybook/stories.js +1 -1
- package/ui.form-input-rating/storybook/stories.js +1 -1
- package/ui.form-input-search/storybook/stories.js +1 -1
- package/ui.form-label/config.js +2 -2
- package/ui.form-label/storybook/stories.js +1 -1
- package/ui.form-radio/config.js +0 -6
- package/ui.form-radio-group/storybook/stories.js +1 -1
- package/ui.form-select/storybook/stories.js +1 -1
- package/ui.form-switch/config.js +0 -6
- package/ui.form-switch/storybook/stories.js +1 -1
- package/ui.form-textarea/storybook/stories.js +1 -1
- package/ui.image-avatar/config.js +0 -5
- package/ui.image-avatar/storybook/stories.js +1 -1
- package/ui.image-icon/UIcon.vue +14 -5
- package/ui.image-icon/config.js +0 -5
- package/ui.image-icon/storybook/stories.js +1 -1
- package/ui.loader/config.js +0 -1
- package/ui.loader/storybook/stories.js +1 -1
- package/ui.loader-overlay/config.js +0 -1
- package/ui.loader-progress/config.js +0 -1
- package/ui.loader-progress/storybook/stories.js +1 -1
- package/ui.navigation-progress/config.js +0 -9
- package/ui.navigation-progress/storybook/stories.js +1 -1
- package/ui.navigation-tabs/storybook/stories.js +1 -1
- package/ui.other-dot/config.js +0 -1
- package/ui.other-dot/storybook/stories.js +1 -1
- package/ui.text-alert/config.js +0 -7
- package/ui.text-alert/storybook/stories.js +1 -1
- package/ui.text-badge/config.js +0 -8
- package/ui.text-badge/storybook/stories.js +2 -10
- package/ui.text-block/UText.vue +62 -18
- package/ui.text-block/storybook/Docs.mdx +3 -3
- package/ui.text-block/storybook/{stories.ts → stories.js} +8 -13
- package/ui.text-block/useAttrs.js +15 -0
- package/ui.text-empty/storybook/stories.js +1 -1
- package/ui.text-file/UFile.vue +15 -12
- package/ui.text-file/config.js +2 -12
- package/ui.text-files/config.js +1 -1
- package/ui.text-header/config.js +0 -1
- package/ui.text-header/storybook/stories.js +1 -1
- package/ui.text-money/config.js +0 -1
- package/ui.text-money/storybook/stories.js +1 -1
- package/ui.text-money/utilMoney.js +2 -2
- package/{utilsTs/utilTheme.ts → utils/utilTheme.js} +27 -31
- package/utils/utilUI.js +205 -1
- package/web-types.json +9580 -0
- package/composablesTs/useAutoPosition.ts +0 -115
- package/composablesTs/useBreakpoint.ts +0 -106
- package/composablesTs/useLocale.ts +0 -25
- package/composablesTs/useMutationObserver.ts +0 -50
- package/composablesTs/useUI.ts +0 -557
- package/constants.ts +0 -73
- package/types.ts +0 -223
- package/ui.text-block/types.ts +0 -33
- package/ui.text-block/useAttrs.ts +0 -20
- package/utilsTs/utilHelper.ts +0 -68
- package/utilsTs/utilPlatform.ts +0 -53
- package/utilsTs/utilStorybook.ts +0 -296
- package/utilsTs/utilTailwind.ts +0 -38
- package/utilsTs/utilUI.ts +0 -143
- /package/ui.text-block/{config.ts → config.js} +0 -0
- /package/ui.text-block/{constants.ts → constants.js} +0 -0
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { computed, toValue, ref } from "vue";
|
|
2
|
-
import { isSSR } from "../utilsTs/utilHelper.ts";
|
|
3
|
-
|
|
4
|
-
import type { Ref, ComputedRef } from "vue";
|
|
5
|
-
|
|
6
|
-
interface PositionXY {
|
|
7
|
-
x: Position;
|
|
8
|
-
y: Position;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export enum Position {
|
|
12
|
-
Left = "left",
|
|
13
|
-
Right = "right",
|
|
14
|
-
Top = "top",
|
|
15
|
-
Bottom = "bottom",
|
|
16
|
-
Auto = "auto",
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// TODO: Remove after full TS migration, use enum instead.
|
|
20
|
-
export const POSITION = {
|
|
21
|
-
left: "left",
|
|
22
|
-
right: "right",
|
|
23
|
-
top: "top",
|
|
24
|
-
bottom: "bottom",
|
|
25
|
-
auto: "auto",
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export function useAutoPosition(
|
|
29
|
-
anchorElement: Ref<HTMLElement | null>,
|
|
30
|
-
targetElement: Ref<HTMLElement | null>,
|
|
31
|
-
position: PositionXY | ComputedRef<PositionXY>,
|
|
32
|
-
preferredPosition: PositionXY | ComputedRef<PositionXY>,
|
|
33
|
-
) {
|
|
34
|
-
const localAnchorElement = computed(() => toValue(anchorElement));
|
|
35
|
-
const localTargetElement = computed(() => toValue(targetElement));
|
|
36
|
-
const localPosition = computed(() => toValue(position));
|
|
37
|
-
const localPreferredPosition = computed(() => toValue(preferredPosition));
|
|
38
|
-
|
|
39
|
-
const preferredOpenDirectionY = ref(localPreferredPosition.value?.y || Position.Bottom);
|
|
40
|
-
const preferredOpenDirectionX = ref(localPreferredPosition.value?.x || Position.Left);
|
|
41
|
-
|
|
42
|
-
const isTop = computed(() => {
|
|
43
|
-
if (localPosition.value.y !== Position.Auto) {
|
|
44
|
-
return localPosition.value.y === Position.Top;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return preferredOpenDirectionY.value === Position.Top;
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const isLeft = computed(() => {
|
|
51
|
-
if (localPosition.value.x !== Position.Auto) {
|
|
52
|
-
return localPosition.value.x === Position.Left;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return preferredOpenDirectionX.value === Position.Left;
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const isBottom = computed(() => {
|
|
59
|
-
if (localPosition.value.y !== Position.Auto) {
|
|
60
|
-
return localPosition.value.y === Position.Bottom;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return preferredOpenDirectionY.value === Position.Bottom;
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
const isRight = computed(() => {
|
|
67
|
-
if (localPosition.value.x !== Position.Auto) {
|
|
68
|
-
return localPosition.value.x === Position.Right;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return preferredOpenDirectionX.value === Position.Right;
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
function adjustPositionY(): void {
|
|
75
|
-
if (isSSR || !localAnchorElement.value || !localTargetElement.value) return;
|
|
76
|
-
|
|
77
|
-
const spaceAbove = localAnchorElement.value.getBoundingClientRect().top;
|
|
78
|
-
const spaceBelow = window.innerHeight - localAnchorElement.value.getBoundingClientRect().bottom;
|
|
79
|
-
const hasEnoughSpaceBelow =
|
|
80
|
-
spaceBelow > localTargetElement.value.getBoundingClientRect().height;
|
|
81
|
-
const hasEnoughSpaceAbove =
|
|
82
|
-
spaceAbove > localTargetElement.value.getBoundingClientRect().height;
|
|
83
|
-
|
|
84
|
-
if (localPreferredPosition.value.y === Position.Bottom) {
|
|
85
|
-
preferredOpenDirectionY.value =
|
|
86
|
-
hasEnoughSpaceBelow || spaceBelow > spaceAbove ? Position.Bottom : Position.Top;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (localPreferredPosition.value.y === Position.Top) {
|
|
90
|
-
preferredOpenDirectionY.value =
|
|
91
|
-
hasEnoughSpaceAbove || spaceAbove > spaceBelow ? Position.Top : Position.Bottom;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function adjustPositionX(): void {
|
|
96
|
-
if (isSSR || !localAnchorElement.value || !localTargetElement.value) return;
|
|
97
|
-
|
|
98
|
-
const spaceRight = localAnchorElement.value.getBoundingClientRect().right;
|
|
99
|
-
const spaceLeft = window.innerWidth - localAnchorElement.value.getBoundingClientRect().left;
|
|
100
|
-
const hasEnoughSpaceLeft = spaceLeft > localTargetElement.value.getBoundingClientRect().width;
|
|
101
|
-
const hasEnoughSpaceRight = spaceRight > localTargetElement.value.getBoundingClientRect().width;
|
|
102
|
-
|
|
103
|
-
if (localPreferredPosition.value.x === Position.Right) {
|
|
104
|
-
preferredOpenDirectionX.value =
|
|
105
|
-
hasEnoughSpaceRight || spaceRight > spaceLeft ? Position.Right : Position.Left;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (localPreferredPosition.value.x === Position.Left) {
|
|
109
|
-
preferredOpenDirectionX.value =
|
|
110
|
-
hasEnoughSpaceLeft || spaceLeft > spaceRight ? Position.Left : Position.Right;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return { isTop, isRight, isBottom, isLeft, adjustPositionY, adjustPositionX };
|
|
115
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { onMounted, ref, watch, computed, onBeforeUnmount } from "vue";
|
|
2
|
-
import { isSSR } from "../utilsTs/utilHelper.ts";
|
|
3
|
-
|
|
4
|
-
import type { Ref } from "vue";
|
|
5
|
-
|
|
6
|
-
const BREAKPOINT_NAME = {
|
|
7
|
-
xs: "xs",
|
|
8
|
-
sm: "sm",
|
|
9
|
-
md: "md",
|
|
10
|
-
lg: "lg",
|
|
11
|
-
xl: "xl",
|
|
12
|
-
"2xl": "2xl",
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const BREAKPOINT = {
|
|
16
|
-
xs: 0,
|
|
17
|
-
sm: 640,
|
|
18
|
-
md: 768,
|
|
19
|
-
lg: 1024,
|
|
20
|
-
xl: 1280,
|
|
21
|
-
"2xl": 1536,
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const mobileDevices = ["xs", "sm"];
|
|
25
|
-
const portableDevices = ["xs", "sm", "md"];
|
|
26
|
-
|
|
27
|
-
export default function useBreakpoint() {
|
|
28
|
-
let timeout: number;
|
|
29
|
-
|
|
30
|
-
const windowWidth: Ref<number | undefined> = ref(undefined);
|
|
31
|
-
const currentBreakpoint = ref(BREAKPOINT_NAME.xs);
|
|
32
|
-
|
|
33
|
-
const isMobileBreakpoint = computed(() => {
|
|
34
|
-
return mobileDevices.includes(currentBreakpoint.value);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
const isTabletBreakpoint = computed(() => {
|
|
38
|
-
return mobileDevices.includes(currentBreakpoint.value);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const isLaptopBreakpoint = computed(() => {
|
|
42
|
-
return currentBreakpoint.value === BREAKPOINT_NAME.lg;
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const isPortableBreakpoint = computed(() => {
|
|
46
|
-
return portableDevices.includes(currentBreakpoint.value);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const elementSize = computed(() => {
|
|
50
|
-
return isMobileBreakpoint.value ? BREAKPOINT_NAME.md : BREAKPOINT_NAME.lg;
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
onMounted(() => {
|
|
54
|
-
if (isSSR) return;
|
|
55
|
-
|
|
56
|
-
windowWidth.value = window.innerWidth;
|
|
57
|
-
|
|
58
|
-
window.addEventListener("resize", resizeListener, { passive: true });
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
onBeforeUnmount(() => {
|
|
62
|
-
if (isSSR) return;
|
|
63
|
-
|
|
64
|
-
window.removeEventListener("resize", resizeListener);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
watch(windowWidth, setBreakpoint, { immediate: true });
|
|
68
|
-
|
|
69
|
-
function resizeListener() {
|
|
70
|
-
if (isSSR) return;
|
|
71
|
-
|
|
72
|
-
if (timeout) {
|
|
73
|
-
window.cancelAnimationFrame(timeout);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
timeout = window.requestAnimationFrame(() => {
|
|
77
|
-
windowWidth.value = window.innerWidth;
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function setBreakpoint(newWindowWidth: number | undefined) {
|
|
82
|
-
if (newWindowWidth === undefined) return;
|
|
83
|
-
|
|
84
|
-
currentBreakpoint.value = "xs";
|
|
85
|
-
|
|
86
|
-
if (newWindowWidth >= BREAKPOINT.sm && newWindowWidth < BREAKPOINT.md) {
|
|
87
|
-
currentBreakpoint.value = "sm";
|
|
88
|
-
} else if (newWindowWidth >= BREAKPOINT.md && newWindowWidth < BREAKPOINT.lg) {
|
|
89
|
-
currentBreakpoint.value = "md";
|
|
90
|
-
} else if (newWindowWidth >= BREAKPOINT.lg && newWindowWidth < BREAKPOINT.xl) {
|
|
91
|
-
currentBreakpoint.value = "lg";
|
|
92
|
-
} else if (newWindowWidth >= BREAKPOINT.xl && newWindowWidth < BREAKPOINT["2xl"]) {
|
|
93
|
-
currentBreakpoint.value = "xl";
|
|
94
|
-
} else if (newWindowWidth >= BREAKPOINT["2xl"]) {
|
|
95
|
-
currentBreakpoint.value = "2xl";
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return {
|
|
100
|
-
isLaptopBreakpoint,
|
|
101
|
-
isTabletBreakpoint,
|
|
102
|
-
isMobileBreakpoint,
|
|
103
|
-
isPortableBreakpoint,
|
|
104
|
-
elementSize,
|
|
105
|
-
};
|
|
106
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { inject } from "vue";
|
|
2
|
-
import createVuelessAdapter from "../adatper.locale/vueless.js";
|
|
3
|
-
|
|
4
|
-
export const LocaleSymbol = Symbol.for("vueless:locale");
|
|
5
|
-
|
|
6
|
-
function isLocaleInstance(obj): boolean {
|
|
7
|
-
return obj.name !== null;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function createLocale(options) {
|
|
11
|
-
const i18n =
|
|
12
|
-
options?.adapter && isLocaleInstance(options?.adapter)
|
|
13
|
-
? options?.adapter
|
|
14
|
-
: createVuelessAdapter(options);
|
|
15
|
-
|
|
16
|
-
return { ...i18n };
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function useLocale() {
|
|
20
|
-
const locale = inject(LocaleSymbol);
|
|
21
|
-
|
|
22
|
-
if (!locale) throw new Error("[vueless] Could not find injected locale instance");
|
|
23
|
-
|
|
24
|
-
return locale;
|
|
25
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { onBeforeUnmount, onMounted, toValue, watch } from "vue";
|
|
2
|
-
import { isSSR } from "../utilsTs/utilHelper.ts";
|
|
3
|
-
|
|
4
|
-
import type { Ref } from "vue";
|
|
5
|
-
|
|
6
|
-
export function useMutationObserver(
|
|
7
|
-
target: Ref<HTMLElement | null>,
|
|
8
|
-
callBack: () => void,
|
|
9
|
-
config = { childList: true, attributes: true, characterData: true },
|
|
10
|
-
) {
|
|
11
|
-
if (isSSR) return;
|
|
12
|
-
|
|
13
|
-
const observer = new MutationObserver(callBack);
|
|
14
|
-
|
|
15
|
-
onMounted(() => {
|
|
16
|
-
if (!toValue(target)) return;
|
|
17
|
-
|
|
18
|
-
if (Array.isArray(toValue(target))) {
|
|
19
|
-
toValue(target).forEach((element) => {
|
|
20
|
-
observer.observe(element, config);
|
|
21
|
-
});
|
|
22
|
-
} else {
|
|
23
|
-
observer.observe(toValue(target), config);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
watch(
|
|
28
|
-
() => toValue(target),
|
|
29
|
-
() => {
|
|
30
|
-
if (Array.isArray(toValue(target))) {
|
|
31
|
-
toValue(target).forEach((element) => {
|
|
32
|
-
observer.observe(element, config);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
observer.observe(toValue(target), config);
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
deep: true,
|
|
42
|
-
},
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
onBeforeUnmount(() => {
|
|
46
|
-
observer.disconnect();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
return { observer };
|
|
50
|
-
}
|