vueless 0.0.514 → 0.0.516

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 (36) hide show
  1. package/package.json +1 -1
  2. package/types.ts +8 -0
  3. package/ui.button-link/useAttrs.ts +2 -2
  4. package/ui.dropdown-badge/UDropdownBadge.vue +70 -167
  5. package/ui.dropdown-badge/storybook/Docs.mdx +2 -2
  6. package/ui.dropdown-badge/storybook/{stories.js → stories.ts} +16 -5
  7. package/ui.dropdown-badge/types.ts +93 -0
  8. package/ui.dropdown-badge/{useAttrs.js → useAttrs.ts} +13 -2
  9. package/ui.dropdown-button/UDropdownButton.vue +85 -203
  10. package/ui.dropdown-button/storybook/Docs.mdx +2 -2
  11. package/ui.dropdown-button/storybook/{stories.js → stories.ts} +25 -11
  12. package/ui.dropdown-button/types.ts +108 -0
  13. package/ui.dropdown-button/{useAttrs.js → useAttrs.ts} +14 -3
  14. package/ui.dropdown-link/UDropdownLink.vue +84 -194
  15. package/ui.dropdown-link/storybook/Docs.mdx +2 -2
  16. package/ui.dropdown-link/storybook/{stories.js → stories.ts} +20 -9
  17. package/ui.dropdown-link/types.ts +103 -0
  18. package/ui.dropdown-link/{useAttrs.js → useAttrs.ts} +14 -3
  19. package/ui.dropdown-list/UDropdownList.vue +112 -177
  20. package/ui.dropdown-list/storybook/Docs.mdx +2 -2
  21. package/ui.dropdown-list/storybook/{stories.js → stories.ts} +23 -7
  22. package/ui.dropdown-list/types.ts +52 -0
  23. package/ui.dropdown-list/{useAttrs.js → useAttrs.ts} +6 -3
  24. package/ui.dropdown-list/usePointer.ts +111 -0
  25. package/ui.text-money/UMoney.vue +1 -1
  26. package/ui.text-money/config.ts +12 -13
  27. package/web-types.json +117 -55
  28. package/ui.dropdown-list/usePointer.js +0 -86
  29. /package/ui.dropdown-badge/{config.js → config.ts} +0 -0
  30. /package/ui.dropdown-badge/{constants.js → constants.ts} +0 -0
  31. /package/ui.dropdown-button/{config.js → config.ts} +0 -0
  32. /package/ui.dropdown-button/{constants.js → constants.ts} +0 -0
  33. /package/ui.dropdown-link/{config.js → config.ts} +0 -0
  34. /package/ui.dropdown-link/{constants.js → constants.ts} +0 -0
  35. /package/ui.dropdown-list/{config.js → config.ts} +0 -0
  36. /package/ui.dropdown-list/{constants.js → constants.ts} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.514",
3
+ "version": "0.0.516",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
package/types.ts CHANGED
@@ -19,6 +19,10 @@ import UCalendarDefaultConfig from "./ui.form-calendar/config.ts";
19
19
  import UDatePickerConfig from "./ui.form-date-picker/config.ts";
20
20
  import UDatePickerRangeConfig from "./ui.form-date-picker-range/config.ts";
21
21
  import UDataTableConfig from "./ui.data-table/config.ts";
22
+ import UDropdownBadgeConfig from "./ui.dropdown-badge/config.ts";
23
+ import UDropdownButtonConfig from "./ui.dropdown-button/config.ts";
24
+ import UDropdownLinkConfig from "./ui.dropdown-link/config.ts";
25
+ import UDropdownListConfig from "./ui.dropdown-list/config.ts";
22
26
  import UAccordionConfig from "./ui.container-accordion/config.ts";
23
27
  import UCardConfig from "./ui.container-card/config.ts";
24
28
  import UColConfig from "./ui.container-col/config.ts";
@@ -152,6 +156,10 @@ export interface Components {
152
156
  UDatePicker?: Partial<typeof UDatePickerConfig>;
153
157
  UDatePickerRange?: Partial<typeof UDatePickerRangeConfig>;
154
158
  UTable?: Partial<typeof UDataTableConfig>;
159
+ UDropdownBadge?: Partial<typeof UDropdownBadgeConfig>;
160
+ UDropdownButton?: Partial<typeof UDropdownButtonConfig>;
161
+ UDropdownLink?: Partial<typeof UDropdownLinkConfig>;
162
+ UDropdownList?: Partial<typeof UDropdownListConfig>;
155
163
  UAccordion?: Partial<typeof UAccordionConfig>;
156
164
  UCard?: Partial<typeof UCardConfig>;
157
165
  UCol?: Partial<typeof UColConfig>;
@@ -7,14 +7,14 @@ import type { Ref } from "vue";
7
7
  import type { UseAttrs } from "../types.ts";
8
8
  import type { ULinkProps, Config } from "./types.ts";
9
9
 
10
- type ActiveState = {
10
+ type ComponentState = {
11
11
  isActive: Ref<boolean>;
12
12
  isExactActive: Ref<boolean>;
13
13
  };
14
14
 
15
15
  export default function useAttrs(
16
16
  props: ULinkProps,
17
- { isActive, isExactActive }: ActiveState,
17
+ { isActive, isExactActive }: ComponentState,
18
18
  ): UseAttrs<Config> {
19
19
  const { config, getKeysAttrs, hasSlotContent, getExtendingKeysClasses } = useUI<Config>(
20
20
  defaultConfig,
@@ -1,3 +1,73 @@
1
+ <script lang="ts" setup>
2
+ import { nextTick, ref, useId } from "vue";
3
+
4
+ import UIcon from "../ui.image-icon/UIcon.vue";
5
+ import UBadge from "../ui.text-badge/UBadge.vue";
6
+ import UDropdownList from "../ui.dropdown-list/UDropdownList.vue";
7
+
8
+ import { getDefault } from "../utils/ui.ts";
9
+
10
+ import { vClickOutside } from "../directives";
11
+
12
+ import defaultConfig from "./config.ts";
13
+ import { UDropdownBadge } from "./constants.ts";
14
+ import useAttrs from "./useAttrs.ts";
15
+
16
+ import type { UDropdownBadgeProps } from "./types.ts";
17
+
18
+ defineOptions({ inheritAttrs: false });
19
+
20
+ const props = withDefaults(defineProps<UDropdownBadgeProps>(), {
21
+ labelKey: getDefault<UDropdownBadgeProps>(defaultConfig, UDropdownBadge).labelKey,
22
+ variant: getDefault<UDropdownBadgeProps>(defaultConfig, UDropdownBadge).variant,
23
+ color: getDefault<UDropdownBadgeProps>(defaultConfig, UDropdownBadge).color,
24
+ size: getDefault<UDropdownBadgeProps>(defaultConfig, UDropdownBadge).size,
25
+ round: getDefault<UDropdownBadgeProps>(defaultConfig, UDropdownBadge).round,
26
+ noIcon: getDefault<UDropdownBadgeProps>(defaultConfig, UDropdownBadge).noIcon,
27
+ yPosition: getDefault<UDropdownBadgeProps>(defaultConfig, UDropdownBadge).yPosition,
28
+ xPosition: getDefault<UDropdownBadgeProps>(defaultConfig, UDropdownBadge).xPosition,
29
+ dataTest: "",
30
+ });
31
+
32
+ const emit = defineEmits([
33
+ /**
34
+ * Triggers on dropdown option click.
35
+ * @property {string} value
36
+ */
37
+ "clickOption",
38
+ ]);
39
+
40
+ const isShownOptions = ref(false);
41
+ const dropdownListRef = ref(null);
42
+
43
+ const elementId = props.id || useId();
44
+
45
+ const { config, wrapperAttrs, dropdownBadgeAttrs, dropdownListAttrs, dropdownIconAttrs } = useAttrs(
46
+ props,
47
+ {
48
+ isShownOptions,
49
+ },
50
+ );
51
+
52
+ function onClickBadge() {
53
+ isShownOptions.value = !isShownOptions.value;
54
+
55
+ if (isShownOptions.value) {
56
+ nextTick(() => dropdownListRef.value.wrapperRef.focus());
57
+ }
58
+ }
59
+
60
+ function hideOptions() {
61
+ isShownOptions.value = false;
62
+ }
63
+
64
+ function onClickOption(option) {
65
+ emit("clickOption", option);
66
+
67
+ hideOptions();
68
+ }
69
+ </script>
70
+
1
71
  <template>
2
72
  <div v-click-outside="hideOptions" v-bind="wrapperAttrs">
3
73
  <UBadge
@@ -61,170 +131,3 @@
61
131
  />
62
132
  </div>
63
133
  </template>
64
-
65
- <script setup>
66
- import { nextTick, ref, useId } from "vue";
67
-
68
- import UIcon from "../ui.image-icon/UIcon.vue";
69
- import UBadge from "../ui.text-badge/UBadge.vue";
70
- import UDropdownList from "../ui.dropdown-list/UDropdownList.vue";
71
-
72
- import { getDefault } from "../utils/ui.ts";
73
-
74
- import { vClickOutside } from "../directives";
75
-
76
- import defaultConfig from "./config.js";
77
- import { UDropdownBadge } from "./constants.js";
78
- import useAttrs from "./useAttrs.js";
79
-
80
- defineOptions({ inheritAttrs: false });
81
-
82
- const props = defineProps({
83
- /**
84
- * Badge label.
85
- */
86
- label: {
87
- type: String,
88
- default: "",
89
- },
90
-
91
- /**
92
- * Options list.
93
- */
94
- options: {
95
- type: Array,
96
- default: () => [],
97
- },
98
-
99
- /**
100
- * Label key in the item object of options.
101
- */
102
- labelKey: {
103
- type: String,
104
- default: getDefault(defaultConfig, UDropdownBadge).labelKey,
105
- },
106
-
107
- /**
108
- * Badge variant.
109
- * @values primary, secondary, thirdary
110
- */
111
- variant: {
112
- type: String,
113
- default: getDefault(defaultConfig, UDropdownBadge).variant,
114
- },
115
-
116
- /**
117
- * Badge color.
118
- * @values brand, grayscale, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, white
119
- */
120
- color: {
121
- type: String,
122
- default: getDefault(defaultConfig, UDropdownBadge).color,
123
- },
124
-
125
- /**
126
- * Badge size.
127
- * @values sm, md, lg
128
- */
129
- size: {
130
- type: String,
131
- default: getDefault(defaultConfig, UDropdownBadge).size,
132
- },
133
-
134
- /**
135
- * Set badge corners rounded.
136
- */
137
- round: {
138
- type: Boolean,
139
- default: getDefault(defaultConfig, UDropdownBadge).round,
140
- },
141
-
142
- /**
143
- * Hide dropdown icon.
144
- */
145
- noIcon: {
146
- type: Boolean,
147
- default: getDefault(defaultConfig, UDropdownBadge).noIcon,
148
- },
149
-
150
- /**
151
- * The position of dropdown list on the y-axis.
152
- * @values top, bottom
153
- */
154
- yPosition: {
155
- type: String,
156
- default: getDefault(defaultConfig, UDropdownBadge).yPosition,
157
- },
158
-
159
- /**
160
- * The position of dropdown list on the x-axis.
161
- * @values left, right
162
- */
163
- xPosition: {
164
- type: String,
165
- default: getDefault(defaultConfig, UDropdownBadge).xPosition,
166
- },
167
-
168
- /**
169
- * Unique element id.
170
- */
171
- id: {
172
- type: String,
173
- default: "",
174
- },
175
-
176
- /**
177
- * Component config object.
178
- */
179
- config: {
180
- type: Object,
181
- default: () => ({}),
182
- },
183
-
184
- /**
185
- * Data-test attribute for automated testing.
186
- */
187
- dataTest: {
188
- type: String,
189
- default: "",
190
- },
191
- });
192
-
193
- const emit = defineEmits([
194
- /**
195
- * Triggers on dropdown option click.
196
- * @property {string} value
197
- */
198
- "clickOption",
199
- ]);
200
-
201
- const isShownOptions = ref(false);
202
- const dropdownListRef = ref(null);
203
-
204
- const elementId = props.id || useId();
205
-
206
- const { config, wrapperAttrs, dropdownBadgeAttrs, dropdownListAttrs, dropdownIconAttrs } = useAttrs(
207
- props,
208
- {
209
- isShownOptions,
210
- },
211
- );
212
-
213
- function onClickBadge() {
214
- isShownOptions.value = !isShownOptions.value;
215
-
216
- if (isShownOptions.value) {
217
- nextTick(() => dropdownListRef.value.wrapperRef.focus());
218
- }
219
- }
220
-
221
- function hideOptions() {
222
- isShownOptions.value = false;
223
- }
224
-
225
- function onClickOption(option) {
226
- emit("clickOption", option);
227
-
228
- hideOptions();
229
- }
230
- </script>
@@ -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} />
@@ -4,6 +4,14 @@ import UDropdownBadge from "../../ui.dropdown-badge/UDropdownBadge.vue";
4
4
  import URow from "../../ui.container-row/URow.vue";
5
5
  import UIcon from "../../ui.image-icon/UIcon.vue";
6
6
 
7
+ import type { Meta, StoryFn } from "@storybook/vue3";
8
+ import type { UDropdownBadgeProps } from "../types.ts";
9
+
10
+ interface UDropdownBadgeArgs extends UDropdownBadgeProps {
11
+ slotTemplate?: string;
12
+ enum: "color" | "size";
13
+ }
14
+
7
15
  /**
8
16
  * The `UDropdownBadge` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.dropdown-badge)
9
17
  */
@@ -25,9 +33,9 @@ export default {
25
33
  },
26
34
  },
27
35
  },
28
- };
36
+ } as Meta;
29
37
 
30
- const DefaultTemplate = (args) => ({
38
+ const DefaultTemplate: StoryFn<UDropdownBadgeArgs> = (args: UDropdownBadgeArgs) => ({
31
39
  components: { UDropdownBadge, UIcon },
32
40
  setup() {
33
41
  const slots = getSlotNames(UDropdownBadge.__name);
@@ -38,17 +46,20 @@ const DefaultTemplate = (args) => ({
38
46
  <UDropdownBadge
39
47
  v-bind="args"
40
48
  >
41
- ${args.slotTemplate || getSlotsFragment()}
49
+ ${args.slotTemplate || getSlotsFragment("")}
42
50
  </UDropdownBadge>
43
51
  `,
44
52
  });
45
53
 
46
- const EnumVariantTemplate = (args, { argTypes }) => ({
54
+ const EnumVariantTemplate: StoryFn<UDropdownBadgeArgs> = (
55
+ args: UDropdownBadgeArgs,
56
+ { argTypes },
57
+ ) => ({
47
58
  components: { UDropdownBadge, URow },
48
59
  setup() {
49
60
  return {
50
61
  args,
51
- options: argTypes[args.enum].options,
62
+ options: argTypes?.[args.enum]?.options,
52
63
  };
53
64
  },
54
65
  template: `
@@ -0,0 +1,93 @@
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 UDropdownBadgeProps {
8
+ /**
9
+ * Badge label.
10
+ */
11
+ label?: string;
12
+
13
+ /**
14
+ * Options list.
15
+ */
16
+ options?: UnknownObject[];
17
+
18
+ /**
19
+ * Label key in the item object of options.
20
+ */
21
+ labelKey?: string;
22
+
23
+ /**
24
+ * Badge variant.
25
+ */
26
+ variant?: "primary" | "secondary" | "thirdary";
27
+
28
+ /**
29
+ * Badge color.
30
+ */
31
+ color?:
32
+ | "brand"
33
+ | "grayscale"
34
+ | "gray"
35
+ | "red"
36
+ | "orange"
37
+ | "amber"
38
+ | "yellow"
39
+ | "lime"
40
+ | "green"
41
+ | "emerald"
42
+ | "teal"
43
+ | "cyan"
44
+ | "sky"
45
+ | "blue"
46
+ | "indigo"
47
+ | "violet"
48
+ | "purple"
49
+ | "fuchsia"
50
+ | "pink"
51
+ | "rose"
52
+ | "white";
53
+
54
+ /**
55
+ * Badge size.
56
+ */
57
+ size?: "sm" | "md" | "lg";
58
+
59
+ /**
60
+ * Set badge corners rounded.
61
+ */
62
+ round?: boolean;
63
+
64
+ /**
65
+ * Hide dropdown icon.
66
+ */
67
+ noIcon?: boolean;
68
+
69
+ /**
70
+ * The position of dropdown list on the y-axis.
71
+ */
72
+ yPosition?: "top" | "bottom";
73
+
74
+ /**
75
+ * The position of dropdown list on the x-axis.
76
+ */
77
+ xPosition?: "left" | "right";
78
+
79
+ /**
80
+ * Unique element id.
81
+ */
82
+ id?: 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,9 +1,20 @@
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, { isShownOptions }) {
6
+ import type { Ref } from "vue";
7
+ import type { UseAttrs } from "../types.ts";
8
+ import type { UDropdownBadgeProps, Config } from "./types.ts";
9
+
10
+ type ComponentState = {
11
+ isShownOptions: Ref<boolean>;
12
+ };
13
+
14
+ export default function useAttrs(
15
+ props: UDropdownBadgeProps,
16
+ { isShownOptions }: ComponentState,
17
+ ): UseAttrs<Config> {
7
18
  const { config, getKeysAttrs, hasSlotContent, getExtendingKeysClasses } = useUI(
8
19
  defaultConfig,
9
20
  () => props.config,