vueless 0.0.532 → 0.0.533

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.
Files changed (48) hide show
  1. package/package.json +1 -1
  2. package/types.ts +12 -0
  3. package/ui.image-avatar/UAvatar.vue +51 -115
  4. package/ui.image-avatar/storybook/Docs.mdx +2 -2
  5. package/ui.image-avatar/storybook/{stories.js → stories.ts} +13 -5
  6. package/ui.image-avatar/types.ts +71 -0
  7. package/ui.image-avatar/useAttrs.ts +18 -0
  8. package/ui.image-icon/UIcon.vue +28 -113
  9. package/ui.image-icon/storybook/Docs.mdx +1 -1
  10. package/ui.image-icon/storybook/{stories.js → stories.ts} +13 -5
  11. package/ui.image-icon/types.ts +83 -0
  12. package/ui.image-icon/useAttrs.ts +18 -0
  13. package/ui.navigation-pagination/UPagination.vue +141 -262
  14. package/ui.navigation-pagination/storybook/Docs.mdx +2 -2
  15. package/ui.navigation-pagination/storybook/{stories.js → stories.ts} +11 -4
  16. package/ui.navigation-pagination/types.ts +85 -0
  17. package/ui.navigation-pagination/{useAttrs.js → useAttrs.ts} +5 -2
  18. package/ui.navigation-progress/StepperProgress.vue +26 -47
  19. package/ui.navigation-progress/UProgress.vue +60 -118
  20. package/ui.navigation-progress/{config.js → config.ts} +1 -0
  21. package/ui.navigation-progress/storybook/Docs.mdx +2 -2
  22. package/ui.navigation-progress/storybook/{stories.js → stories.ts} +19 -7
  23. package/ui.navigation-progress/types.ts +93 -0
  24. package/ui.navigation-progress/{useAttrs.js → useAttrs.ts} +6 -3
  25. package/ui.navigation-tab/UTab.vue +18 -54
  26. package/ui.navigation-tab/storybook/Docs.mdx +2 -2
  27. package/ui.navigation-tab/storybook/{stories.js → stories.ts} +10 -5
  28. package/ui.navigation-tab/types.ts +30 -0
  29. package/ui.navigation-tab/{useAttrs.js → useAttrs.ts} +15 -3
  30. package/ui.navigation-tabs/UTabs.vue +29 -78
  31. package/ui.navigation-tabs/storybook/Docs.mdx +2 -2
  32. package/ui.navigation-tabs/storybook/{stories.js → stories.ts} +13 -5
  33. package/ui.navigation-tabs/types.ts +37 -0
  34. package/ui.navigation-tabs/useAttrs.ts +18 -0
  35. package/web-types.json +146 -77
  36. package/ui.image-avatar/useAttrs.js +0 -15
  37. package/ui.image-icon/useAttrs.js +0 -15
  38. package/ui.navigation-tabs/useAttrs.js +0 -15
  39. /package/ui.image-avatar/{config.js → config.ts} +0 -0
  40. /package/ui.image-avatar/{constants.js → constants.ts} +0 -0
  41. /package/ui.image-icon/{constants.js → constants.ts} +0 -0
  42. /package/ui.navigation-pagination/{config.js → config.ts} +0 -0
  43. /package/ui.navigation-pagination/{constants.js → constants.ts} +0 -0
  44. /package/ui.navigation-progress/{constants.js → constants.ts} +0 -0
  45. /package/ui.navigation-tab/{config.js → config.ts} +0 -0
  46. /package/ui.navigation-tab/{constants.js → constants.ts} +0 -0
  47. /package/ui.navigation-tabs/{config.js → config.ts} +0 -0
  48. /package/ui.navigation-tabs/{constants.js → constants.ts} +0 -0
@@ -1,88 +1,21 @@
1
- <template>
2
- <div :data-test="dataTest" v-bind="tabsAttrs">
3
- <!-- @slot Use it to add the UTab component. -->
4
- <slot>
5
- <UTab
6
- v-for="(item, index) in options"
7
- :key="item.value"
8
- :label="item.label"
9
- :value="item.value"
10
- :disabled="item.disabled"
11
- :size="size"
12
- :data-test="`${dataTest}-item-${index}`"
13
- v-bind="itemAttrs"
14
- />
15
- </slot>
16
- </div>
17
- </template>
18
-
19
- <script setup>
1
+ <script lang="ts" setup>
20
2
  import { computed, provide } from "vue";
21
3
 
22
4
  import UTab from "../ui.navigation-tab/UTab.vue";
23
5
  import { getDefault } from "../utils/ui.ts";
24
6
 
25
- import { UTabs } from "./constants.js";
26
- import defaultConfig from "./config.js";
27
- import useAttrs from "./useAttrs.js";
28
-
29
- defineOptions({ inheritAttrs: false });
30
-
31
- const props = defineProps({
32
- /**
33
- * Selected tab value.
34
- */
35
- modelValue: {
36
- type: String,
37
- default: "",
38
- },
39
-
40
- /**
41
- * Tab options.
42
- */
43
- options: {
44
- type: Array,
45
- default: () => [
46
- {
47
- label: "",
48
- value: "",
49
- disabled: false,
50
- },
51
- ],
52
- },
53
-
54
- /**
55
- * Tabs size.
56
- * @values sm, md, lg
57
- */
58
- size: {
59
- type: String,
60
- default: getDefault(defaultConfig, UTabs).size,
61
- },
7
+ import { UTabs } from "./constants.ts";
8
+ import defaultConfig from "./config.ts";
9
+ import useAttrs from "./useAttrs.ts";
62
10
 
63
- /**
64
- * Add the bottom line along the entire length.
65
- */
66
- underlined: {
67
- type: Boolean,
68
- default: getDefault(defaultConfig, UTabs).underlined,
69
- },
11
+ import type { UTabsProps } from "./types.ts";
70
12
 
71
- /**
72
- * Component config object.
73
- */
74
- config: {
75
- type: Object,
76
- default: () => ({}),
77
- },
13
+ defineOptions({ inheritAttrs: false });
78
14
 
79
- /**
80
- * Data-test attribute for automated testing.
81
- */
82
- dataTest: {
83
- type: String,
84
- default: "",
85
- },
15
+ const props = withDefaults(defineProps<UTabsProps>(), {
16
+ size: getDefault<UTabsProps>(defaultConfig, UTabs).size,
17
+ underlined: getDefault<UTabsProps>(defaultConfig, UTabs).underlined,
18
+ dataTest: "",
86
19
  });
87
20
 
88
21
  const emit = defineEmits([
@@ -98,9 +31,27 @@ const selectedItem = computed({
98
31
  set: (value) => emit("update:modelValue", value),
99
32
  });
100
33
 
101
- provide("setUTabsSelectedItem", (value) => (selectedItem.value = value));
34
+ provide("setUTabsSelectedItem", (value: string) => (selectedItem.value = value));
102
35
  provide("getUTabsSelectedItem", () => selectedItem.value);
103
36
  provide("getUTabsSize", () => props.size);
104
37
 
105
38
  const { tabsAttrs, itemAttrs } = useAttrs(props);
106
39
  </script>
40
+
41
+ <template>
42
+ <div :data-test="dataTest" v-bind="tabsAttrs">
43
+ <!-- @slot Use it to add the UTab component. -->
44
+ <slot>
45
+ <UTab
46
+ v-for="(item, index) in options"
47
+ :key="item.value"
48
+ :label="item.label"
49
+ :value="item.value"
50
+ :disabled="item.disabled"
51
+ :size="size"
52
+ :data-test="`${dataTest}-item-${index}`"
53
+ v-bind="itemAttrs"
54
+ />
55
+ </slot>
56
+ </div>
57
+ </template>
@@ -1,8 +1,8 @@
1
1
  import { Meta, Title, Subtitle, Description, Primary, Controls, Stories, Source } from "@storybook/blocks";
2
2
  import { getSource } from "../../utils/storybook.ts";
3
3
 
4
- import * as stories from "./stories.js";
5
- import defaultConfig from "../config.js?raw"
4
+ import * as stories from "./stories.ts";
5
+ import defaultConfig from "../config.ts?raw"
6
6
 
7
7
  <Meta of={stories} />
8
8
  <Title of={stories} />
@@ -2,6 +2,14 @@ import { getArgTypes, getSlotNames, getSlotsFragment } from "../../utils/storybo
2
2
 
3
3
  import UTabs from "../../ui.navigation-tabs/UTabs.vue";
4
4
 
5
+ import type { Meta, StoryFn } from "@storybook/vue3";
6
+ import type { UTabsProps } from "../types.ts";
7
+
8
+ interface UTabsArgs extends UTabsProps {
9
+ slotTemplate?: string;
10
+ enum: "size";
11
+ }
12
+
5
13
  /**
6
14
  * The `UTabs` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.navigation-tabs)
7
15
  */
@@ -20,9 +28,9 @@ export default {
20
28
  argTypes: {
21
29
  ...getArgTypes(UTabs.__name),
22
30
  },
23
- };
31
+ } as Meta;
24
32
 
25
- const DefaultTemplate = (args) => ({
33
+ const DefaultTemplate: StoryFn<UTabsArgs> = (args: UTabsArgs) => ({
26
34
  components: { UTabs },
27
35
  setup() {
28
36
  const slots = getSlotNames(UTabs.__name);
@@ -31,17 +39,17 @@ const DefaultTemplate = (args) => ({
31
39
  },
32
40
  template: `
33
41
  <UTabs v-bind="args" v-model="args.modelValue">
34
- ${args.slotTemplate || getSlotsFragment()}
42
+ ${args.slotTemplate || getSlotsFragment("")}
35
43
  </UTabs>
36
44
  `,
37
45
  });
38
46
 
39
- const EnumVariantTemplate = (args, { argTypes }) => ({
47
+ const EnumVariantTemplate: StoryFn<UTabsArgs> = (args: UTabsArgs, { argTypes }) => ({
40
48
  components: { UTabs },
41
49
  setup() {
42
50
  return {
43
51
  args,
44
- options: argTypes[args.enum].options,
52
+ options: argTypes?.[args.enum]?.options,
45
53
  };
46
54
  },
47
55
  template: `
@@ -0,0 +1,37 @@
1
+ import defaultConfig from "./config.ts";
2
+
3
+ import type { UnknownObject } from "../types.ts";
4
+
5
+ export type Config = Partial<typeof defaultConfig>;
6
+
7
+ export interface UTabsProps {
8
+ /**
9
+ * Selected tab value.
10
+ */
11
+ modelValue?: string;
12
+
13
+ /**
14
+ * Tab options.
15
+ */
16
+ options?: UnknownObject[];
17
+
18
+ /**
19
+ * Tabs size.
20
+ */
21
+ size?: "sm" | "md" | "lg";
22
+
23
+ /**
24
+ * Add the bottom line along the entire length.
25
+ */
26
+ underlined?: boolean;
27
+
28
+ /**
29
+ * Component config object.
30
+ */
31
+ config?: Partial<typeof defaultConfig>;
32
+
33
+ /**
34
+ * Data-test attribute for automated testing.
35
+ */
36
+ dataTest?: string;
37
+ }
@@ -0,0 +1,18 @@
1
+ import useUI from "../composables/useUI.ts";
2
+
3
+ import defaultConfig from "./config.ts";
4
+
5
+ import type { UseAttrs } from "../types.ts";
6
+ import type { UTabsProps, Config } from "./types.ts";
7
+
8
+ export default function useAttrs(props: UTabsProps): UseAttrs<Config> {
9
+ const { config, getKeysAttrs, hasSlotContent } = useUI<Config>(defaultConfig, () => props.config);
10
+
11
+ const keysAttrs = getKeysAttrs();
12
+
13
+ return {
14
+ config,
15
+ ...keysAttrs,
16
+ hasSlotContent,
17
+ };
18
+ }