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,3 +1,62 @@
1
+ <script lang="ts" setup>
2
+ import { computed } from "vue";
3
+
4
+ import { getDefault } from "../utils/ui.ts";
5
+ import useAttrs from "./useAttrs.ts";
6
+
7
+ import defaultConfig from "./config.ts";
8
+ import { UProgress, VARIANT } from "./constants.ts";
9
+
10
+ import StepperProgress from "./StepperProgress.vue";
11
+ import UHeader from "../ui.text-header/UHeader.vue";
12
+
13
+ import type { UProgressProps } from "./types.ts";
14
+
15
+ defineOptions({ inheritAttrs: false });
16
+
17
+ const props = withDefaults(defineProps<UProgressProps>(), {
18
+ value: 0,
19
+ max: getDefault<UProgressProps>(defaultConfig, UProgress).max as number,
20
+ size: getDefault<UProgressProps>(defaultConfig, UProgress).size,
21
+ color: getDefault<UProgressProps>(defaultConfig, UProgress).color,
22
+ variant: getDefault<UProgressProps>(defaultConfig, UProgress).variant,
23
+ indicator: getDefault<UProgressProps>(defaultConfig, UProgress).indicator,
24
+ dataTest: "",
25
+ });
26
+
27
+ const { progressAttrs, wrapperAttrs, indicatorAttrs, stepAttrs, stepperAttrs } = useAttrs(props);
28
+
29
+ const isSteps = computed(() => Array.isArray(props.max));
30
+
31
+ const realMax = computed(() => {
32
+ if (Array.isArray(props.max)) {
33
+ return props.max.length - 1;
34
+ }
35
+
36
+ return Number(props.max);
37
+ });
38
+
39
+ const isVariant = computed(() => ({
40
+ stepper: props.variant === VARIANT.stepper,
41
+ progress: props.variant === VARIANT.progress,
42
+ }));
43
+
44
+ const progressPercent = computed(() => {
45
+ const maxPercent = 100;
46
+ const currentPercent = (props.value / realMax.value) * maxPercent;
47
+
48
+ if (isVariant.value.progress) {
49
+ return `${currentPercent}%`;
50
+ }
51
+
52
+ return `${currentPercent} ${maxPercent}`;
53
+ });
54
+
55
+ function isActiveStep(index: number) {
56
+ return index === props.value;
57
+ }
58
+ </script>
59
+
1
60
  <template>
2
61
  <div v-bind="wrapperAttrs">
3
62
  <template v-if="isVariant.progress">
@@ -32,7 +91,7 @@
32
91
  :value="value"
33
92
  :max="max"
34
93
  >
35
- <UHeader v-if="isVariant.stepper" :label="step" :size="size" />
94
+ <UHeader v-if="isVariant.stepper" :label="String(step)" :size="size" />
36
95
  <template v-else>{{ step }}</template>
37
96
  </slot>
38
97
  </template>
@@ -48,120 +107,3 @@
48
107
  />
49
108
  </div>
50
109
  </template>
51
-
52
- <script setup>
53
- import { computed } from "vue";
54
-
55
- import { getDefault } from "../utils/ui.ts";
56
- import useAttrs from "./useAttrs.js";
57
-
58
- import defaultConfig from "./config.js";
59
- import { UProgress, VARIANT } from "./constants.js";
60
-
61
- import StepperProgress from "./StepperProgress.vue";
62
- import UHeader from "../ui.text-header/UHeader.vue";
63
-
64
- defineOptions({ inheritAttrs: false });
65
-
66
- const props = defineProps({
67
- /**
68
- * Progress value (current step).
69
- */
70
- value: {
71
- type: Number,
72
- required: true,
73
- default: 0,
74
- },
75
-
76
- /**
77
- * Progress max amount of steps.
78
- */
79
- max: {
80
- type: [Number, Array],
81
- default: 100,
82
- },
83
-
84
- /**
85
- * Progress size.
86
- * @values 2xs, xs, sm, md, lg, xl, 2xl
87
- */
88
- size: {
89
- type: String,
90
- default: getDefault(defaultConfig, UProgress).size,
91
- },
92
-
93
- /**
94
- * Progress color.
95
- * @values brand, grayscale, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, white
96
- */
97
- color: {
98
- type: String,
99
- default: getDefault(defaultConfig, UProgress).color,
100
- },
101
-
102
- /**
103
- * Progress variant.
104
- * @values stepper, progress
105
- */
106
- variant: {
107
- type: String,
108
- default: getDefault(defaultConfig, UProgress).variant,
109
- },
110
-
111
- /**
112
- * Progress indicator visibility.
113
- */
114
- indicator: {
115
- type: Boolean,
116
- default: getDefault(defaultConfig, UProgress).indicator,
117
- },
118
-
119
- /**
120
- * Component config object.
121
- */
122
- config: {
123
- type: Object,
124
- default: () => ({}),
125
- },
126
-
127
- /**
128
- * Data-test attribute for automated testing.
129
- */
130
- dataTest: {
131
- type: String,
132
- default: "",
133
- },
134
- });
135
-
136
- const { progressAttrs, wrapperAttrs, indicatorAttrs, stepAttrs, stepperAttrs } = useAttrs(props);
137
-
138
- const isSteps = computed(() => Array.isArray(props.max));
139
-
140
- const realMax = computed(() => {
141
- if (isSteps.value) {
142
- return props.max.length - 1;
143
- }
144
-
145
- return Number(props.max);
146
- });
147
-
148
- const isVariant = computed(() => ({
149
- stepper: props.variant === VARIANT.stepper,
150
- progress: props.variant === VARIANT.progress,
151
- }));
152
-
153
- const progressPercent = computed(() => {
154
- const maxPercent = 100;
155
- const currentPercent = (props.value / realMax.value) * maxPercent;
156
-
157
- if (isVariant.value.progress) {
158
- return `${currentPercent}%`;
159
- }
160
-
161
- return `${currentPercent} ${maxPercent}`;
162
- });
163
-
164
- function isActiveStep(index) {
165
- return index === props.value;
166
- }
167
- </script>
@@ -102,6 +102,7 @@ export default /*tw*/ {
102
102
  },
103
103
  },
104
104
  defaults: {
105
+ max: 100,
105
106
  color: "brand",
106
107
  size: "md",
107
108
  variant: "progress",
@@ -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} />
@@ -5,6 +5,16 @@ import UCol from "../../ui.container-col/UCol.vue";
5
5
  import UButton from "../../ui.button/UButton.vue";
6
6
  import UIcon from "../../ui.image-icon/UIcon.vue";
7
7
 
8
+ import type { Meta, StoryFn } from "@storybook/vue3";
9
+ import type { UProgressProps } from "../types.ts";
10
+
11
+ interface UProgressArgs extends UProgressProps {
12
+ slotTemplate?: string;
13
+ enum: "color" | "size";
14
+ iterator?: number;
15
+ progress?: number;
16
+ }
17
+
8
18
  /**
9
19
  * The `UProgress` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.navigation-progress)
10
20
  */
@@ -15,9 +25,9 @@ export default {
15
25
  argTypes: {
16
26
  ...getArgTypes(UProgress.__name),
17
27
  },
18
- };
28
+ } as Meta;
19
29
 
20
- const DefaultTemplate = (args) => ({
30
+ const DefaultTemplate: StoryFn<UProgressArgs> = (args: UProgressArgs) => ({
21
31
  components: { UCol, UProgress, UButton, UIcon },
22
32
  setup() {
23
33
  const slots = getSlotNames(UProgress.__name);
@@ -26,29 +36,31 @@ const DefaultTemplate = (args) => ({
26
36
  args.iterator = args.max ? 1 : 10;
27
37
 
28
38
  function updateProgress() {
29
- args.value = args.value < (args.max?.length - 1 || 100) ? args.value + args.iterator : 0;
39
+ const maxValue = Array.isArray(args.max) ? args.max.length - 1 : 100;
40
+
41
+ args.value = args.value < maxValue ? args.value + (args.iterator || 0) : 0;
30
42
  }
31
43
 
32
44
  return { slots, args, updateProgress };
33
45
  },
34
46
  template: `
35
47
  <UCol>
36
- <UProgress v-bind="args">${args.slotTemplate || getSlotsFragment()}</UProgress>
48
+ <UProgress v-bind="args">${args.slotTemplate || getSlotsFragment("")}</UProgress>
37
49
  <UButton label="Next →" size="sm" variant="thirdary" filled @click="updateProgress" />
38
50
  </UCol>
39
51
  `,
40
52
  });
41
53
 
42
- const EnumVariantTemplate = (args, { argTypes }) => ({
54
+ const EnumVariantTemplate: StoryFn<UProgressArgs> = (args: UProgressArgs, { argTypes }) => ({
43
55
  components: { UCol, UButton, UProgress },
44
56
  setup() {
45
57
  args.progress = 10;
46
58
 
47
59
  function updateProgress() {
48
- args.progress = args.progress < 100 ? args.progress + 10 : 0;
60
+ args.progress = args.progress && args.progress < 100 ? args.progress + 10 : 0;
49
61
  }
50
62
 
51
- return { args, updateProgress, options: argTypes[args.enum].options };
63
+ return { args, updateProgress, options: argTypes?.[args.enum]?.options };
52
64
  },
53
65
  template: `
54
66
  <UCol>
@@ -0,0 +1,93 @@
1
+ import defaultConfig from "./config.ts";
2
+
3
+ export type Config = Partial<typeof defaultConfig>;
4
+
5
+ export interface UProgressProps {
6
+ /**
7
+ * Progress value (current step).
8
+ */
9
+ value: number;
10
+
11
+ /**
12
+ * Progress max amount of steps.
13
+ */
14
+ max?: number | (string | number)[];
15
+
16
+ /**
17
+ * Progress size.
18
+ */
19
+ size?: "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl";
20
+
21
+ /**
22
+ * Progress color.
23
+ */
24
+ color?:
25
+ | "brand"
26
+ | "grayscale"
27
+ | "gray"
28
+ | "red"
29
+ | "orange"
30
+ | "amber"
31
+ | "yellow"
32
+ | "lime"
33
+ | "green"
34
+ | "emerald"
35
+ | "teal"
36
+ | "cyan"
37
+ | "sky"
38
+ | "blue"
39
+ | "indigo"
40
+ | "violet"
41
+ | "purple"
42
+ | "fuchsia"
43
+ | "pink"
44
+ | "rose"
45
+ | "white";
46
+
47
+ /**
48
+ * Progress variant.
49
+ */
50
+ variant?: "stepper" | "progress";
51
+
52
+ /**
53
+ * Progress indicator visibility.
54
+ */
55
+ indicator?: boolean;
56
+
57
+ /**
58
+ * Component config object.
59
+ */
60
+ config?: Partial<typeof defaultConfig>;
61
+
62
+ /**
63
+ * Data-test attribute for automated testing.
64
+ */
65
+ dataTest?: string;
66
+ }
67
+
68
+ export interface StepperProgressProps {
69
+ /**
70
+ * Stepper progress percent value.
71
+ */
72
+ progressPercent: string;
73
+
74
+ /**
75
+ * Stepper progress value (current step).
76
+ */
77
+ value: number;
78
+
79
+ /**
80
+ * Stepper progress color.
81
+ */
82
+ color: string;
83
+
84
+ /**
85
+ * Component config object.
86
+ */
87
+ config?: Partial<typeof defaultConfig>;
88
+
89
+ /**
90
+ * Data-test attribute for automated testing.
91
+ */
92
+ dataTest?: string;
93
+ }
@@ -1,10 +1,13 @@
1
1
  import { computed } from "vue";
2
2
  import useUI from "../composables/useUI.ts";
3
3
 
4
- import defaultConfig from "./config.js";
4
+ import defaultConfig from "./config.ts";
5
5
 
6
- export default function useAttrs(props) {
7
- const { config, getKeysAttrs, hasSlotContent, getExtendingKeysClasses } = useUI(
6
+ import type { UseAttrs } from "../types.ts";
7
+ import type { UProgressProps, Config } from "./types.ts";
8
+
9
+ export default function useAttrs(props: UProgressProps): UseAttrs<Config> {
10
+ const { config, getKeysAttrs, hasSlotContent, getExtendingKeysClasses } = useUI<Config>(
8
11
  defaultConfig,
9
12
  () => props.config,
10
13
  );
@@ -1,20 +1,13 @@
1
- <template>
2
- <div v-bind="tabAttrs" :data-test="dataTest" @click="onClickSetValue">
3
- <!-- @slot Use it to add something instead of the label. -->
4
- <slot>
5
- {{ label }}
6
- </slot>
7
- </div>
8
- </template>
9
-
10
- <script setup>
1
+ <script lang="ts" setup>
11
2
  import { computed, inject, toValue } from "vue";
12
3
 
13
4
  import { getDefault } from "../utils/ui.ts";
14
5
 
15
- import { UTab } from "./constants.js";
16
- import defaultConfig from "./config.js";
17
- import useAttrs from "./useAttrs.js";
6
+ import { UTab } from "./constants.ts";
7
+ import defaultConfig from "./config.ts";
8
+ import useAttrs from "./useAttrs.ts";
9
+
10
+ import type { UTabProps } from "./types.ts";
18
11
 
19
12
  defineOptions({ inheritAttrs: false });
20
13
 
@@ -22,47 +15,9 @@ const setUTabsSelectedItem = inject("setUTabsSelectedItem", null);
22
15
  const getUTabsSelectedItem = inject("getUTabsSelectedItem", null);
23
16
  const getUTabsSize = inject("getUTabsSize", null);
24
17
 
25
- const props = defineProps({
26
- /**
27
- * Tab label.
28
- * @ignore
29
- */
30
- label: {
31
- type: String,
32
- required: true,
33
- },
34
-
35
- /**
36
- * Tab value.
37
- */
38
- value: {
39
- type: [String, Number],
40
- default: "",
41
- },
42
-
43
- /**
44
- * Make tab disabled.
45
- */
46
- disabled: {
47
- type: Boolean,
48
- default: getDefault(defaultConfig, UTab).disabled,
49
- },
50
-
51
- /**
52
- * Component config object.
53
- */
54
- config: {
55
- type: Object,
56
- default: () => ({}),
57
- },
58
-
59
- /**
60
- * Data-test attribute for automated testing.
61
- */
62
- dataTest: {
63
- type: String,
64
- default: "",
65
- },
18
+ const props = withDefaults(defineProps<UTabProps>(), {
19
+ disabled: getDefault<UTabProps>(defaultConfig, UTab).disabled,
20
+ dataTest: "",
66
21
  });
67
22
 
68
23
  const selected = computed(() => {
@@ -81,3 +36,12 @@ async function onClickSetValue() {
81
36
  }
82
37
  }
83
38
  </script>
39
+
40
+ <template>
41
+ <div v-bind="tabAttrs" :data-test="dataTest" @click="onClickSetValue">
42
+ <!-- @slot Use it to add something instead of the label. -->
43
+ <slot>
44
+ {{ label }}
45
+ </slot>
46
+ </div>
47
+ </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} />
@@ -3,6 +3,13 @@ import { getArgTypes, getSlotNames, getSlotsFragment } from "../../utils/storybo
3
3
  import UTab from "../../ui.navigation-tab/UTab.vue";
4
4
  import UIcon from "../../ui.image-icon/UIcon.vue";
5
5
 
6
+ import type { Meta, StoryFn } from "@storybook/vue3";
7
+ import type { UTabProps } from "../types.ts";
8
+
9
+ interface UTabArgs extends UTabProps {
10
+ slotTemplate?: string;
11
+ }
12
+
6
13
  /**
7
14
  * The `UTab` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.navigation-tab)
8
15
  */
@@ -16,9 +23,9 @@ export default {
16
23
  argTypes: {
17
24
  ...getArgTypes(UTab.__name),
18
25
  },
19
- };
26
+ } as Meta;
20
27
 
21
- const DefaultTemplate = (args) => ({
28
+ const DefaultTemplate: StoryFn<UTabArgs> = (args: UTabArgs) => ({
22
29
  components: { UTab, UIcon },
23
30
  setup() {
24
31
  const slots = getSlotNames(UTab.__name);
@@ -27,7 +34,7 @@ const DefaultTemplate = (args) => ({
27
34
  },
28
35
  template: `
29
36
  <UTab v-bind="args">
30
- ${args.slotTemplate || getSlotsFragment()}
37
+ ${args.slotTemplate || getSlotsFragment("")}
31
38
  </UTab>
32
39
  `,
33
40
  });
@@ -40,12 +47,10 @@ Disabled.args = { disabled: true };
40
47
 
41
48
  export const SlotDefault = DefaultTemplate.bind({});
42
49
  SlotDefault.args = {
43
- label: "Tag",
44
50
  slotTemplate: `
45
51
  <template #default>
46
52
  <div class="flex items-center">
47
53
  <UIcon name="star" size="sm" />
48
- {{label}}
49
54
  </div>
50
55
  </template>
51
56
  `,
@@ -0,0 +1,30 @@
1
+ import defaultConfig from "./config.ts";
2
+
3
+ export type Config = Partial<typeof defaultConfig>;
4
+
5
+ export interface UTabProps {
6
+ /**
7
+ * Tab label.
8
+ */
9
+ label: string;
10
+
11
+ /**
12
+ * Tab value.
13
+ */
14
+ value?: string | number;
15
+
16
+ /**
17
+ * Make tab disabled.
18
+ */
19
+ disabled?: boolean;
20
+
21
+ /**
22
+ * Component config object.
23
+ */
24
+ config?: Partial<typeof defaultConfig>;
25
+
26
+ /**
27
+ * Data-test attribute for automated testing.
28
+ */
29
+ dataTest?: string;
30
+ }
@@ -1,10 +1,22 @@
1
+ import { computed } from "vue";
1
2
  import useUI from "../composables/useUI.ts";
2
3
 
3
4
  import defaultConfig from "./config.js";
4
- import { computed } from "vue";
5
5
 
6
- export default function useAttrs(props, { selected, size }) {
7
- const { config, getKeysAttrs, hasSlotContent, getExtendingKeysClasses } = useUI(
6
+ import type { Ref } from "vue";
7
+ import type { UseAttrs } from "../types.ts";
8
+ import type { UTabProps, Config } from "./types.ts";
9
+
10
+ type ComponentState = {
11
+ selected: Ref<boolean>;
12
+ size: Ref<string>;
13
+ };
14
+
15
+ export default function useAttrs(
16
+ props: UTabProps,
17
+ { selected, size }: ComponentState,
18
+ ): UseAttrs<Config> {
19
+ const { config, getKeysAttrs, hasSlotContent, getExtendingKeysClasses } = useUI<Config>(
8
20
  defaultConfig,
9
21
  () => props.config,
10
22
  );