@toife/vue 3.0.3 → 3.0.5
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/package.json +1 -1
- package/src/components/action/action.composable.ts +1 -0
- package/src/components/action/action.scss +4 -3
- package/src/components/action/action.type.ts +10 -1
- package/src/components/action/action.vue +12 -10
- package/src/components/app/app.scss +4 -4
- package/src/components/app/app.type.ts +9 -0
- package/src/components/app/app.vue +8 -7
- package/src/components/avatar/avatar.scss +2 -2
- package/src/components/avatar/avatar.type.ts +1 -1
- package/src/components/avatar/avatar.vue +4 -13
- package/src/components/button/button.scss +24 -26
- package/src/components/button/button.type.ts +1 -1
- package/src/components/button/button.vue +8 -8
- package/src/components/cable/cable.type.ts +1 -1
- package/src/components/cable/cable.vue +8 -8
- package/src/components/card/card/card.scss +5 -4
- package/src/components/card/card/card.type.ts +1 -1
- package/src/components/card/card/card.vue +6 -6
- package/src/components/card/card-body/card-body.scss +4 -4
- package/src/components/card/card-footer/card-footer.scss +7 -6
- package/src/components/card/card-footer/card-footer.vue +4 -4
- package/src/components/card/card-header/card-header.scss +7 -6
- package/src/components/card/card-header/card-header.vue +4 -4
- package/src/components/checkbox/checkbox.html +0 -1
- package/src/components/checkbox/checkbox.scss +20 -20
- package/src/components/checkbox/checkbox.vue +8 -8
- package/src/components/collapse/collapse.scss +7 -7
- package/src/components/collapse/collapse.type.ts +1 -1
- package/src/components/collapse/collapse.vue +15 -19
- package/src/components/container/container.vue +1 -0
- package/src/components/decision-modal/decision-modal.composable.ts +1 -0
- package/src/components/decision-modal/decision-modal.scss +5 -4
- package/src/components/decision-modal/decision-modal.type.ts +1 -1
- package/src/components/decision-modal/decision-modal.vue +11 -11
- package/src/components/divider/divider.scss +4 -4
- package/src/components/divider/divider.vue +4 -4
- package/src/components/field/field.type.ts +1 -1
- package/src/components/field/field.vue +7 -6
- package/src/components/field/outline/outline.scss +13 -12
- package/src/components/field/outline/outline.vue +10 -10
- package/src/components/form-group/form-group.vue +4 -4
- package/src/components/gesture-indicator/gesture-indicator.scss +2 -2
- package/src/components/gesture-indicator/gesture-indicator.type.ts +1 -1
- package/src/components/gesture-indicator/gesture-indicator.vue +5 -5
- package/src/components/image/image.type.ts +1 -1
- package/src/components/image/image.vue +10 -13
- package/src/components/modal/modal.scss +2 -2
- package/src/components/modal/modal.vue +11 -9
- package/src/components/page/page.vue +1 -0
- package/src/components/present/present.composable.ts +1 -0
- package/src/components/present/present.scss +3 -3
- package/src/components/present/present.vue +12 -12
- package/src/components/radio/radio/radio.scss +26 -21
- package/src/components/radio/radio/radio.type.ts +1 -1
- package/src/components/radio/radio/radio.vue +8 -8
- package/src/components/radio/radio-group/radio-group.vue +6 -6
- package/src/components/refresher/refresher.type.ts +1 -1
- package/src/components/refresher/refresher.vue +11 -11
- package/src/components/route/route-navigator/route-navigator.type.ts +24 -0
- package/src/components/route/route-navigator/route-navigator.vue +33 -16
- package/src/components/route/route-outlet/route-outlet.vue +20 -11
- package/src/components/route/route-provider/route-provider.vue +6 -6
- package/src/components/route/route-wrapper/route-wrapper.composable.ts +4 -3
- package/src/components/route/route-wrapper/route-wrapper.vue +7 -5
- package/src/components/route/route.util.ts +1 -0
- package/src/components/segmented-field/segmented-field.scss +4 -3
- package/src/components/segmented-field/segmented-field.vue +8 -8
- package/src/components/skeleton/skeleton.scss +14 -9
- package/src/components/skeleton/skeleton.type.ts +1 -1
- package/src/components/skeleton/skeleton.vue +4 -4
- package/src/components/switch/switch.html +0 -1
- package/src/components/switch/switch.scss +15 -14
- package/src/components/switch/switch.type.ts +1 -1
- package/src/components/switch/switch.vue +8 -8
- package/src/components/tabs/tab/tab.type.ts +1 -1
- package/src/components/tabs/tab/tab.vue +6 -6
- package/src/components/tabs/tabs/tabs.scss +14 -15
- package/src/components/tabs/tabs/tabs.type.ts +1 -1
- package/src/components/tabs/tabs/tabs.vue +13 -13
- package/src/components/toast/toast/toast.vue +6 -6
- package/src/components/toast/toast-content/toast-content.scss +8 -8
- package/src/components/toast/toast-content/toast-content.vue +7 -7
- package/src/components/toast/toast.composable.ts +1 -1
- package/src/components/toolbar/toolbar.scss +2 -2
- package/src/components/toolbar/toolbar.type.ts +1 -1
- package/src/components/toolbar/toolbar.vue +4 -4
- package/src/factory.ts +2 -1
- package/src/utils/element.ts +6 -0
- package/src/utils/events.ts +8 -2
- package/src/utils/style/index.ts +17 -2
- package/src/components/image/image.scss +0 -1
|
@@ -2,29 +2,38 @@
|
|
|
2
2
|
<script lang="ts" setup>
|
|
3
3
|
import { markRaw, onMounted, ref } from "vue";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
// Component setup (props, emits, injects)
|
|
6
|
+
// ----------------------------------------------------------------------------
|
|
7
7
|
const props = defineProps<{
|
|
8
8
|
component: unknown;
|
|
9
9
|
}>();
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
// Reactive state
|
|
12
|
+
// ----------------------------------------------------------------------------
|
|
13
13
|
const renderComponent = ref<unknown | null>(null);
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
// Methods
|
|
16
|
+
// ----------------------------------------------------------------------------
|
|
17
17
|
const resolveComponent = async (raw: unknown): Promise<unknown> => {
|
|
18
18
|
if (typeof raw !== "function") return raw;
|
|
19
19
|
const mod = await (raw as () => Promise<{ default?: unknown }>)();
|
|
20
20
|
return mod?.default ?? mod;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
/** Accepts a component, async loader, or `{ default }` wrapper (common for vue-router). */
|
|
24
|
+
const resolveFromProp = async (raw: unknown): Promise<unknown | null> => {
|
|
25
|
+
if (raw == null) return null;
|
|
26
|
+
const inner =
|
|
27
|
+
typeof raw === "object" && raw !== null && "default" in raw
|
|
28
|
+
? (raw as { default: unknown }).default
|
|
29
|
+
: raw;
|
|
30
|
+
return resolveComponent(inner);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// Lifecycle
|
|
34
|
+
// ----------------------------------------------------------------------------
|
|
25
35
|
onMounted(async () => {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
renderComponent.value = component ? markRaw(component) : null;
|
|
36
|
+
const resolved = await resolveFromProp(props.component);
|
|
37
|
+
renderComponent.value = resolved ? markRaw(resolved) : null;
|
|
29
38
|
});
|
|
30
39
|
</script>
|
|
@@ -4,16 +4,16 @@ import { ROUTE_PROVIDER_STATE_KEY } from "./route-provider.constant";
|
|
|
4
4
|
import { type RouteProviderProps, type RouteProviderState } from "./route-provider.type";
|
|
5
5
|
import { provide, computed } from "vue";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
// Component setup (props, emits, injects)
|
|
8
|
+
// ----------------------------------------------------------------------------
|
|
9
9
|
const props = defineProps<RouteProviderProps>();
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
// Computed properties
|
|
12
|
+
// ----------------------------------------------------------------------------
|
|
13
13
|
const stack = computed(() => props.stack);
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
// Provide / expose (public API)
|
|
16
|
+
// ----------------------------------------------------------------------------
|
|
17
17
|
provide<RouteProviderState>(ROUTE_PROVIDER_STATE_KEY, {
|
|
18
18
|
stack,
|
|
19
19
|
});
|
|
@@ -5,6 +5,7 @@ import { RouteWrapperOption } from "./route-wrapper.type";
|
|
|
5
5
|
|
|
6
6
|
const stack = shallowRef<RouteStack[]>([]);
|
|
7
7
|
|
|
8
|
+
/** Recursively builds a nested stack from vue-router `matched` for the navigator. */
|
|
8
9
|
const buildTree = (
|
|
9
10
|
matched: RouteLocationMatched[],
|
|
10
11
|
current: RouteStack[],
|
|
@@ -12,12 +13,12 @@ const buildTree = (
|
|
|
12
13
|
) => {
|
|
13
14
|
if (matched.length === 0) return current;
|
|
14
15
|
|
|
15
|
-
//
|
|
16
|
+
// User navigated back: drop the leaf so we merge into the parent segment
|
|
16
17
|
if (current.length > 1 && current[current.length - 2]?.name === matched[0].name) {
|
|
17
18
|
current.pop();
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
//
|
|
21
|
+
// Same route record: update nested stack only
|
|
21
22
|
if (
|
|
22
23
|
current.length > 0 &&
|
|
23
24
|
current[current.length - 1] &&
|
|
@@ -30,7 +31,7 @@ const buildTree = (
|
|
|
30
31
|
option
|
|
31
32
|
);
|
|
32
33
|
}
|
|
33
|
-
//
|
|
34
|
+
// Push a new segment (forward navigation)
|
|
34
35
|
else {
|
|
35
36
|
const name = String(matched[0].name);
|
|
36
37
|
const component = matched[0].components as RouteComponent;
|
|
@@ -6,15 +6,17 @@ import { useRouter, useRoute } from "vue-router";
|
|
|
6
6
|
import type { RouteWrapperProps } from "./route-wrapper.type";
|
|
7
7
|
import { RouteProvider } from "../route-provider";
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const router = useRouter();
|
|
9
|
+
// Component setup (props, emits, injects)
|
|
10
|
+
// ----------------------------------------------------------------------------
|
|
12
11
|
const props = withDefaults(defineProps<RouteWrapperProps>(), {
|
|
13
12
|
homeRouteName: "home",
|
|
14
13
|
});
|
|
14
|
+
const { updateRoutes, stack } = useRouteWrapper();
|
|
15
|
+
const route = useRoute();
|
|
16
|
+
const router = useRouter();
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
// Lifecycle
|
|
19
|
+
// ----------------------------------------------------------------------------
|
|
18
20
|
watch(
|
|
19
21
|
() => route.matched,
|
|
20
22
|
() => {
|
|
@@ -6,10 +6,11 @@ $segmented-field-content: sass.fn-naming-prefix("segmented-field-content");
|
|
|
6
6
|
$segmented-field-message: sass.fn-naming-prefix("segmented-field-message");
|
|
7
7
|
$segmented-field-help: sass.fn-naming-prefix("segmented-field-help");
|
|
8
8
|
|
|
9
|
-
// Property name
|
|
9
|
+
// Property name - layer: segmented-field
|
|
10
|
+
$segmented-field-color: sass.fn-naming-var("segmented-field", "color");
|
|
11
|
+
|
|
10
12
|
$spacing-x: sass.fn-naming-var("spacing", "x");
|
|
11
13
|
$transition-duration: sass.fn-naming-var("motion", "duration");
|
|
12
|
-
$role-color: sass.fn-naming-var("segmented-field", "background-color");
|
|
13
14
|
$app-color: sass.fn-naming-var("app", "color");
|
|
14
15
|
|
|
15
16
|
.#{$segmented-field-wrapper} {
|
|
@@ -20,7 +21,7 @@ $app-color: sass.fn-naming-var("app", "color");
|
|
|
20
21
|
|
|
21
22
|
// Message
|
|
22
23
|
.#{$segmented-field-message} {
|
|
23
|
-
color: rgb(#{$
|
|
24
|
+
color: rgb(#{$segmented-field-color});
|
|
24
25
|
font-size: 0.9em;
|
|
25
26
|
line-height: 1.5;
|
|
26
27
|
transition:
|
|
@@ -7,8 +7,8 @@ import type { SegmentedFieldProps, SegmentedFieldEmit } from "./segmented-field.
|
|
|
7
7
|
import { withPrefix } from "../../utils";
|
|
8
8
|
import { type AppProviderState, APP_PROVIDER_STATE_KEY } from "../app";
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
// Component setup (props, emits, injects)
|
|
11
|
+
// ----------------------------------------------------------------------------
|
|
12
12
|
const props = withDefaults(defineProps<SegmentedFieldProps>(), {
|
|
13
13
|
modelValue: undefined,
|
|
14
14
|
value: undefined,
|
|
@@ -26,13 +26,13 @@ const props = withDefaults(defineProps<SegmentedFieldProps>(), {
|
|
|
26
26
|
const emit = defineEmits<SegmentedFieldEmit>();
|
|
27
27
|
const appState = inject<AppProviderState>(APP_PROVIDER_STATE_KEY);
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
// Reactive state
|
|
30
|
+
// ----------------------------------------------------------------------------
|
|
31
31
|
const keepValue = ref<string[]>([]);
|
|
32
32
|
const fields = ref<InstanceType<typeof Field>[]>([]);
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
// Computed properties
|
|
35
|
+
// ----------------------------------------------------------------------------
|
|
36
36
|
const segments = computed(() => {
|
|
37
37
|
let value: string[] | undefined = [];
|
|
38
38
|
if (props.value !== undefined && props.value.length > 0) value = props.value;
|
|
@@ -93,8 +93,8 @@ const nextIndex = computed(() => {
|
|
|
93
93
|
return nextIndex;
|
|
94
94
|
});
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
// Methods
|
|
97
|
+
// ----------------------------------------------------------------------------
|
|
98
98
|
const updateValue = (newValue: string[]) => {
|
|
99
99
|
keepValue.value = newValue;
|
|
100
100
|
emit("update:modelValue", newValue);
|
|
@@ -3,21 +3,21 @@
|
|
|
3
3
|
// Classes
|
|
4
4
|
$skeleton: sass.fn-naming-prefix("skeleton");
|
|
5
5
|
|
|
6
|
-
//
|
|
7
|
-
$width: sass.fn-naming-var("skeleton", "width");
|
|
8
|
-
$height: sass.fn-naming-var("skeleton", "height");
|
|
6
|
+
// Property name - layer: skeleton
|
|
7
|
+
$skeleton-width: sass.fn-naming-var("skeleton", "width");
|
|
8
|
+
$skeleton-height: sass.fn-naming-var("skeleton", "height");
|
|
9
|
+
$skeleton-background-color: sass.fn-naming-var("skeleton", "background-color");
|
|
10
|
+
|
|
9
11
|
$border-radius: sass.fn-naming-var("border-radius");
|
|
10
|
-
$background-color: sass.fn-naming-var("skeleton", "background-color");
|
|
11
|
-
$background-color-subtle: sass.fn-naming-var("skeleton", "background-color", "subtle");
|
|
12
12
|
$transition-duration: sass.fn-naming-var("motion", "duration");
|
|
13
13
|
|
|
14
14
|
.#{$skeleton} {
|
|
15
|
-
width: #{$width};
|
|
16
|
-
height: #{$height};
|
|
15
|
+
width: #{$skeleton-width};
|
|
16
|
+
height: #{$skeleton-height};
|
|
17
17
|
position: relative;
|
|
18
18
|
overflow: hidden;
|
|
19
19
|
border-radius: #{$border-radius};
|
|
20
|
-
background-color: rgba(#{$background-color
|
|
20
|
+
background-color: rgba(#{$skeleton-background-color}, 0.2);
|
|
21
21
|
display: inline-block;
|
|
22
22
|
line-height: 0;
|
|
23
23
|
transition:
|
|
@@ -32,7 +32,12 @@ $transition-duration: sass.fn-naming-var("motion", "duration");
|
|
|
32
32
|
position: absolute;
|
|
33
33
|
inset: 0;
|
|
34
34
|
transform: translateX(-100%);
|
|
35
|
-
background: linear-gradient(
|
|
35
|
+
background: linear-gradient(
|
|
36
|
+
90deg,
|
|
37
|
+
transparent,
|
|
38
|
+
rgba(#{$skeleton-background-color}, 1),
|
|
39
|
+
transparent
|
|
40
|
+
);
|
|
36
41
|
opacity: 0.2;
|
|
37
42
|
animation: shimmer 1.2s infinite;
|
|
38
43
|
}
|
|
@@ -6,16 +6,16 @@ import { type SkeletonProps } from "./skeleton.type";
|
|
|
6
6
|
import { property, withPrefix } from "../../utils";
|
|
7
7
|
import { type AppProviderState, APP_PROVIDER_STATE_KEY } from "../app";
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
// Component setup (props, emits, injects)
|
|
10
|
+
// ----------------------------------------------------------------------------
|
|
11
11
|
const props = withDefaults(defineProps<SkeletonProps>(), {
|
|
12
12
|
width: "100%",
|
|
13
13
|
height: "1rem",
|
|
14
14
|
});
|
|
15
15
|
const appState = inject<AppProviderState>(APP_PROVIDER_STATE_KEY);
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
// Computed properties
|
|
18
|
+
// ----------------------------------------------------------------------------
|
|
19
19
|
const skeletonAttrs = computed(() => {
|
|
20
20
|
const shape = props.shape || appState?.shape.value || "";
|
|
21
21
|
const role = props.role || appState?.role.value || "";
|
|
@@ -7,14 +7,15 @@ $shape-rounded: sass.fn-naming-prefix("shape-rounded");
|
|
|
7
7
|
$shape-pill: sass.fn-naming-prefix("shape-pill");
|
|
8
8
|
$switch-wrapper: sass.fn-naming-prefix("switch-wrapper");
|
|
9
9
|
|
|
10
|
-
//
|
|
11
|
-
$background-color: sass.fn-naming-var("switch", "background-color");
|
|
12
|
-
$background-color-hover: sass.fn-naming-var("switch", "background-color", "
|
|
13
|
-
$background-color-inactive: sass.fn-naming-var("switch", "background-color", "
|
|
14
|
-
$background-color-disabled: sass.fn-naming-var("switch", "background-color", "
|
|
15
|
-
$background-color-contrast: sass.fn-naming-var("switch", "background-color", "contrast");
|
|
16
|
-
|
|
17
|
-
$color-
|
|
10
|
+
// Property name - layer: switch (track + thumb; states like button + inactive)
|
|
11
|
+
$switch-background-color: sass.fn-naming-var("switch", "background-color");
|
|
12
|
+
$switch-background-color-hover: sass.fn-naming-var("switch", "background-color", "hover");
|
|
13
|
+
$switch-background-color-inactive: sass.fn-naming-var("switch", "background-color", "inactive");
|
|
14
|
+
$switch-background-color-disabled: sass.fn-naming-var("switch", "background-color", "disabled");
|
|
15
|
+
$switch-background-color-contrast: sass.fn-naming-var("switch", "background-color", "contrast");
|
|
16
|
+
|
|
17
|
+
$switch-border-color-focus: sass.fn-naming-var("switch", "border-color", "focus");
|
|
18
|
+
|
|
18
19
|
$transition-duration: sass.fn-naming-var("motion", "duration");
|
|
19
20
|
$border-radius: sass.fn-naming-var("border-radius");
|
|
20
21
|
$spacing-x: sass.fn-naming-var("spacing", "x");
|
|
@@ -43,7 +44,7 @@ $spacing-x: sass.fn-naming-var("spacing", "x");
|
|
|
43
44
|
height: calc(100% - 0.3rem);
|
|
44
45
|
position: absolute;
|
|
45
46
|
top: 0;
|
|
46
|
-
background-color: rgb(#{$background-color-contrast});
|
|
47
|
+
background-color: rgb(#{$switch-background-color-contrast});
|
|
47
48
|
border-radius: #{$border-radius};
|
|
48
49
|
aspect-ratio: 1/1;
|
|
49
50
|
margin: 0.15rem;
|
|
@@ -72,7 +73,7 @@ $spacing-x: sass.fn-naming-var("spacing", "x");
|
|
|
72
73
|
cursor: not-allowed;
|
|
73
74
|
|
|
74
75
|
.#{$switch} {
|
|
75
|
-
background-color: rgb(#{$background-color-disabled});
|
|
76
|
+
background-color: rgb(#{$switch-background-color-disabled});
|
|
76
77
|
cursor: not-allowed;
|
|
77
78
|
opacity: 0.3;
|
|
78
79
|
}
|
|
@@ -88,21 +89,21 @@ $spacing-x: sass.fn-naming-var("spacing", "x");
|
|
|
88
89
|
|
|
89
90
|
&:not(.on) {
|
|
90
91
|
.#{$switch} {
|
|
91
|
-
background-color: rgb(#{$background-color-inactive});
|
|
92
|
+
background-color: rgb(#{$switch-background-color-inactive});
|
|
92
93
|
|
|
93
94
|
.#{$switch-icon} {
|
|
94
95
|
left: 0;
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
&:not(.disabled):not(.readonly):hover {
|
|
98
|
-
background-color: rgb(#{$background-color-hover});
|
|
99
|
+
background-color: rgb(#{$switch-background-color-hover});
|
|
99
100
|
}
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
&.on {
|
|
104
105
|
.#{$switch} {
|
|
105
|
-
background-color: rgb(#{$background-color});
|
|
106
|
+
background-color: rgb(#{$switch-background-color});
|
|
106
107
|
|
|
107
108
|
.#{$switch-icon} {
|
|
108
109
|
right: 0;
|
|
@@ -115,7 +116,7 @@ $spacing-x: sass.fn-naming-var("spacing", "x");
|
|
|
115
116
|
&.focus {
|
|
116
117
|
&.shadow {
|
|
117
118
|
.#{$switch} {
|
|
118
|
-
box-shadow: 0 0 0 0.25rem rgb(#{$border-color}, 0.25);
|
|
119
|
+
box-shadow: 0 0 0 0.25rem rgb(#{$switch-border-color-focus}, 0.25);
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
122
|
}
|
|
@@ -6,8 +6,8 @@ import type { SwitchProps, SwitchEmit } from "./switch.type";
|
|
|
6
6
|
import { withPrefix } from "../../utils";
|
|
7
7
|
import { type AppProviderState, APP_PROVIDER_STATE_KEY } from "../app";
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
// Component setup (props, emits, injects)
|
|
10
|
+
// ----------------------------------------------------------------------------
|
|
11
11
|
const props = withDefaults(defineProps<SwitchProps>(), {
|
|
12
12
|
modelValue: false,
|
|
13
13
|
readonly: false,
|
|
@@ -16,12 +16,12 @@ const props = withDefaults(defineProps<SwitchProps>(), {
|
|
|
16
16
|
const emit = defineEmits<SwitchEmit>();
|
|
17
17
|
const appState = inject<AppProviderState>(APP_PROVIDER_STATE_KEY);
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
// Reactive state
|
|
20
|
+
// ----------------------------------------------------------------------------
|
|
21
21
|
const isFocused = ref(false);
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
// Computed properties
|
|
24
|
+
// ----------------------------------------------------------------------------
|
|
25
25
|
const switchWrapperAttrs = computed(() => {
|
|
26
26
|
const shadow = (props?.shadow !== undefined ? props.shadow : appState?.shadow.value) ?? false;
|
|
27
27
|
return {
|
|
@@ -56,8 +56,8 @@ const switchIconAttrs = {
|
|
|
56
56
|
class: [withPrefix("switch-icon")],
|
|
57
57
|
} as const;
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
// Methods
|
|
60
|
+
// ----------------------------------------------------------------------------
|
|
61
61
|
const onSwitch = () => {
|
|
62
62
|
if (props.disabled || props.readonly) return;
|
|
63
63
|
emit("update:modelValue", !props.modelValue);
|
|
@@ -6,15 +6,15 @@ import { type TabProps } from "./tab.type";
|
|
|
6
6
|
import { withPrefix } from "../../../utils";
|
|
7
7
|
import { type TabsProviderState, TABS_PROVIDER_STATE_KEY } from "../tabs";
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
// Component setup (props, emits, injects)
|
|
10
|
+
// ----------------------------------------------------------------------------
|
|
11
11
|
const props = withDefaults(defineProps<TabProps>(), {
|
|
12
12
|
disabled: false,
|
|
13
13
|
});
|
|
14
14
|
const tabsState = inject<TabsProviderState>(TABS_PROVIDER_STATE_KEY);
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
// Computed properties
|
|
17
|
+
// ----------------------------------------------------------------------------
|
|
18
18
|
const role = computed(() => tabsState?.role.value || "");
|
|
19
19
|
const shape = computed(() => tabsState?.shape.value || "");
|
|
20
20
|
const isActive = computed(() => tabsState?.activeValue.value === props.value);
|
|
@@ -29,8 +29,8 @@ const tabAttrs = computed(() => {
|
|
|
29
29
|
};
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
// Methods
|
|
33
|
+
// ----------------------------------------------------------------------------
|
|
34
34
|
const handleClick = () => {
|
|
35
35
|
if (props.disabled) return;
|
|
36
36
|
tabsState?.setValue(props.value || "");
|
|
@@ -5,19 +5,18 @@ $tabs: sass.fn-naming-prefix("tabs");
|
|
|
5
5
|
$tab: sass.fn-naming-prefix("tab");
|
|
6
6
|
$button: sass.fn-naming-prefix("button");
|
|
7
7
|
|
|
8
|
-
// Property name
|
|
8
|
+
// Property name - layer: tabs
|
|
9
|
+
$tabs-color: sass.fn-naming-var("tabs", "color");
|
|
10
|
+
$tabs-background-color: sass.fn-naming-var("tabs", "background-color");
|
|
11
|
+
$tabs-border-color: sass.fn-naming-var("tabs", "border-color");
|
|
12
|
+
|
|
9
13
|
$space-x: sass.fn-naming-var("spacing", "x");
|
|
10
14
|
$space-y: sass.fn-naming-var("spacing", "y");
|
|
11
|
-
|
|
12
|
-
// layer: tabs
|
|
13
|
-
$button-color: sass.fn-naming-var("tabs", "color");
|
|
14
15
|
$border-radius: sass.fn-naming-var("border-radius");
|
|
15
16
|
$border-width: sass.fn-naming-var("stroke", "width");
|
|
16
|
-
$border-color: sass.fn-naming-var("tabs", "border-color");
|
|
17
|
-
|
|
18
17
|
$transition-duration: sass.fn-naming-var("motion", "duration");
|
|
19
|
-
$background-color: sass.fn-naming-var("tabs", "background-color");
|
|
20
18
|
|
|
19
|
+
// layer: highlight (indicator geometry)
|
|
21
20
|
$highlight-top: sass.fn-naming-var("highlight", "top");
|
|
22
21
|
$highlight-left: sass.fn-naming-var("highlight", "left");
|
|
23
22
|
$highlight-width: sass.fn-naming-var("highlight", "width");
|
|
@@ -54,7 +53,7 @@ $highlight-space-y: sass.fn-naming-var("highlight", "space-y");
|
|
|
54
53
|
height: #{$highlight-height};
|
|
55
54
|
transform: translate(#{$highlight-left}, #{$highlight-top});
|
|
56
55
|
box-sizing: border-box;
|
|
57
|
-
background-color: rgb(#{$background-color});
|
|
56
|
+
background-color: rgb(#{$tabs-background-color});
|
|
58
57
|
border-radius: #{$border-radius};
|
|
59
58
|
}
|
|
60
59
|
|
|
@@ -114,25 +113,25 @@ $highlight-space-y: sass.fn-naming-var("highlight", "space-y");
|
|
|
114
113
|
&.top-start,
|
|
115
114
|
&.top-center,
|
|
116
115
|
&.top-end {
|
|
117
|
-
border-bottom-color: rgb(#{$border-color});
|
|
116
|
+
border-bottom-color: rgb(#{$tabs-border-color});
|
|
118
117
|
}
|
|
119
118
|
|
|
120
119
|
&.bottom-start,
|
|
121
120
|
&.bottom-center,
|
|
122
121
|
&.bottom-end {
|
|
123
|
-
border-top-color: rgb(#{$border-color});
|
|
122
|
+
border-top-color: rgb(#{$tabs-border-color});
|
|
124
123
|
}
|
|
125
124
|
|
|
126
125
|
&.left-start,
|
|
127
126
|
&.left-center,
|
|
128
127
|
&.left-end {
|
|
129
|
-
border-right-color: rgb(#{$border-color});
|
|
128
|
+
border-right-color: rgb(#{$tabs-border-color});
|
|
130
129
|
}
|
|
131
130
|
|
|
132
131
|
&.right-start,
|
|
133
132
|
&.right-center,
|
|
134
133
|
&.right-end {
|
|
135
|
-
border-left-color: rgb(#{$border-color});
|
|
134
|
+
border-left-color: rgb(#{$tabs-border-color});
|
|
136
135
|
}
|
|
137
136
|
}
|
|
138
137
|
|
|
@@ -162,7 +161,7 @@ $highlight-space-y: sass.fn-naming-var("highlight", "space-y");
|
|
|
162
161
|
:deep(.#{$tab}) {
|
|
163
162
|
&.active {
|
|
164
163
|
.#{$button} {
|
|
165
|
-
color: rgb(#{$
|
|
164
|
+
color: rgb(#{$tabs-color}) !important;
|
|
166
165
|
}
|
|
167
166
|
}
|
|
168
167
|
}
|
|
@@ -196,8 +195,8 @@ $highlight-space-y: sass.fn-naming-var("highlight", "space-y");
|
|
|
196
195
|
:deep(.#{$tab}) {
|
|
197
196
|
&.active {
|
|
198
197
|
.#{$button} {
|
|
199
|
-
color: rgb(#{$background-color});
|
|
200
|
-
text-shadow: 0 0 rgb(#{$background-color});
|
|
198
|
+
color: rgb(#{$tabs-background-color});
|
|
199
|
+
text-shadow: 0 0 rgb(#{$tabs-background-color});
|
|
201
200
|
}
|
|
202
201
|
}
|
|
203
202
|
}
|
|
@@ -7,8 +7,8 @@ import { property, withPrefix } from "../../../utils";
|
|
|
7
7
|
import { type AppProviderState, APP_PROVIDER_STATE_KEY } from "../../app";
|
|
8
8
|
import { TABS_PROVIDER_STATE_KEY } from "./tabs.constants";
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
// Component setup (props, emits, injects)
|
|
11
|
+
// ----------------------------------------------------------------------------
|
|
12
12
|
const props = withDefaults(defineProps<TabsProps>(), {
|
|
13
13
|
placement: "top-start",
|
|
14
14
|
margin: () => [0, 0],
|
|
@@ -16,19 +16,19 @@ const props = withDefaults(defineProps<TabsProps>(), {
|
|
|
16
16
|
divider: undefined,
|
|
17
17
|
transition: true,
|
|
18
18
|
});
|
|
19
|
-
const appState = inject<AppProviderState>(APP_PROVIDER_STATE_KEY);
|
|
20
19
|
const emit = defineEmits<TabsEmit>();
|
|
20
|
+
const appState = inject<AppProviderState>(APP_PROVIDER_STATE_KEY);
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
// Reactive state
|
|
23
|
+
// ----------------------------------------------------------------------------
|
|
24
24
|
const width = ref(0);
|
|
25
25
|
const height = ref(0);
|
|
26
26
|
const top = ref(0);
|
|
27
27
|
const left = ref(0);
|
|
28
28
|
const container = ref();
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
// Computed properties
|
|
31
|
+
// ----------------------------------------------------------------------------
|
|
32
32
|
const role = computed(() => {
|
|
33
33
|
return props.role || appState?.role.value || "";
|
|
34
34
|
});
|
|
@@ -55,7 +55,7 @@ const tabsAttrs = computed(() => {
|
|
|
55
55
|
w = w + props.margin[1] * 2;
|
|
56
56
|
|
|
57
57
|
if (props.variant === "underline") {
|
|
58
|
-
|
|
58
|
+
// Underline variant: align the highlight strip for top vs bottom tab bars
|
|
59
59
|
if (props.placement.startsWith("top-")) {
|
|
60
60
|
t = h - props.border;
|
|
61
61
|
}
|
|
@@ -106,8 +106,8 @@ const tabsAttrs = computed(() => {
|
|
|
106
106
|
};
|
|
107
107
|
});
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
// Methods
|
|
110
|
+
// ----------------------------------------------------------------------------
|
|
111
111
|
const calcPosition = () => {
|
|
112
112
|
let active = container.value.querySelector(".active");
|
|
113
113
|
if (active) {
|
|
@@ -125,7 +125,7 @@ const calcPosition = () => {
|
|
|
125
125
|
};
|
|
126
126
|
|
|
127
127
|
// Lifecycle
|
|
128
|
-
|
|
128
|
+
// ----------------------------------------------------------------------------
|
|
129
129
|
watch(
|
|
130
130
|
() => props.modelValue,
|
|
131
131
|
async () => {
|
|
@@ -144,8 +144,8 @@ onUnmounted(() => {
|
|
|
144
144
|
window.removeEventListener("resize", calcPosition);
|
|
145
145
|
});
|
|
146
146
|
|
|
147
|
-
//
|
|
148
|
-
|
|
147
|
+
// Provide / expose (public API)
|
|
148
|
+
// ----------------------------------------------------------------------------
|
|
149
149
|
provide<TabsProviderState>(TABS_PROVIDER_STATE_KEY, {
|
|
150
150
|
activeValue,
|
|
151
151
|
role,
|
|
@@ -7,15 +7,15 @@ import { withPrefix } from "../../../utils";
|
|
|
7
7
|
import { useToast } from "../toast.composable";
|
|
8
8
|
import { ToastContent } from "../toast-content";
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
// Component setup (props, emits, injects)
|
|
11
|
+
// ----------------------------------------------------------------------------
|
|
12
12
|
const props = withDefaults(defineProps<ToastProps>(), {
|
|
13
13
|
placement: "bottom-end",
|
|
14
14
|
});
|
|
15
15
|
const toast = useToast();
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
// Computed properties
|
|
18
|
+
// ----------------------------------------------------------------------------
|
|
19
19
|
const toastAttrs = computed(() => {
|
|
20
20
|
return {
|
|
21
21
|
class: [withPrefix("toast"), props.placement],
|
|
@@ -26,8 +26,8 @@ const toastMessages = computed(() => {
|
|
|
26
26
|
return toast.messages.value.filter((item) => item.placement == props.placement);
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
// Methods
|
|
30
|
+
// ----------------------------------------------------------------------------
|
|
31
31
|
const dismiss = (id: number) => {
|
|
32
32
|
toast.close(id);
|
|
33
33
|
};
|