vueless 0.0.544 → 0.0.546

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.544",
3
+ "version": "0.0.546",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
@@ -19,7 +19,6 @@ import type { Option } from "../ui.dropdown-list/types.ts";
19
19
  defineOptions({ inheritAttrs: false });
20
20
 
21
21
  const props = withDefaults(defineProps<UDropdownBadgeProps>(), {
22
- label: getDefault<UDropdownBadgeProps>(defaultConfig, UDropdownBadge).label,
23
22
  options: () => [],
24
23
  labelKey: getDefault<UDropdownBadgeProps>(defaultConfig, UDropdownBadge).labelKey,
25
24
  variant: getDefault<UDropdownBadgeProps>(defaultConfig, UDropdownBadge).variant,
@@ -19,7 +19,6 @@ import type { Option } from "../ui.dropdown-list/types.ts";
19
19
  defineOptions({ inheritAttrs: false });
20
20
 
21
21
  const props = withDefaults(defineProps<UDropdownButtonProps>(), {
22
- label: getDefault<UDropdownButtonProps>(defaultConfig, UDropdownButton).label,
23
22
  options: () => [],
24
23
  labelKey: getDefault<UDropdownButtonProps>(defaultConfig, UDropdownButton).labelKey,
25
24
  variant: getDefault<UDropdownButtonProps>(defaultConfig, UDropdownButton).variant,
@@ -20,7 +20,6 @@ defineOptions({ inheritAttrs: false });
20
20
 
21
21
  const props = withDefaults(defineProps<UDropdownLinkProps>(), {
22
22
  options: () => [],
23
- label: getDefault<UDropdownLinkProps>(defaultConfig, UDropdownLink).label,
24
23
  labelKey: getDefault<UDropdownLinkProps>(defaultConfig, UDropdownLink).labelKey,
25
24
  color: getDefault<UDropdownLinkProps>(defaultConfig, UDropdownLink).color,
26
25
  size: getDefault<UDropdownLinkProps>(defaultConfig, UDropdownLink).size,
@@ -85,7 +85,7 @@ const addOptionKeyCombination = computed(() => {
85
85
  });
86
86
 
87
87
  watch(
88
- () => props.options,
88
+ () => [props.options, props.size],
89
89
  () => {
90
90
  nextTick(() => {
91
91
  const options = [
@@ -100,10 +100,35 @@ watch(
100
100
 
101
101
  const maxHeight = options
102
102
  .slice(0, props.visibleOptions)
103
- .map((el) => el.getBoundingClientRect().height)
103
+ .map((el) => {
104
+ const elHeight = el.getBoundingClientRect().height;
105
+
106
+ const styles = window.getComputedStyle(el);
107
+ const marginTop = parseFloat(styles.marginTop || "0");
108
+ const marginBottom = parseFloat(styles.marginBottom || "0");
109
+
110
+ const [childDiv] = el.getElementsByTagName("div");
111
+ const childStyles = childDiv && window.getComputedStyle(childDiv);
112
+ const childMarginTop = parseFloat(childStyles?.marginTop || "0");
113
+ const childMarginBottom = parseFloat(childStyles?.marginBottom || "0");
114
+
115
+ return elHeight + marginTop + marginBottom + childMarginTop + childMarginBottom;
116
+ })
104
117
  .reduce((acc, cur) => acc + cur, 0);
105
118
 
106
- wrapperMaxHeight.value = `${maxHeight + 10}px`;
119
+ const wrapperStyle = getComputedStyle(wrapperRef.value as Element);
120
+ const wrapperPaddingTop = parseFloat(wrapperStyle.paddingTop || "0");
121
+ const wrapperPaddingBottom = parseFloat(wrapperStyle.paddingBottom || "0");
122
+ const wrapperBorderTop = parseFloat(wrapperStyle.borderTopWidth || "0");
123
+ const wrapperBorderBottom = parseFloat(wrapperStyle.borderBottomWidth || "0");
124
+
125
+ wrapperMaxHeight.value = `${
126
+ maxHeight +
127
+ wrapperPaddingTop +
128
+ wrapperPaddingBottom +
129
+ wrapperBorderTop +
130
+ wrapperBorderBottom
131
+ }px`;
107
132
  });
108
133
  },
109
134
  { immediate: true },
@@ -134,7 +159,7 @@ function isSelectedOption(option: Option) {
134
159
  }
135
160
 
136
161
  function getMarginForSubCategory(level: number = 0) {
137
- const baseMargin = 1;
162
+ const baseMargin = 0.5;
138
163
 
139
164
  if (level > 1) {
140
165
  return `margin-left: ${baseMargin * (level - 1)}rem`;
@@ -1,16 +1,16 @@
1
1
  export default /*tw*/ {
2
2
  wrapper: `
3
- my-2 flex w-full absolute right-0 z-50
4
- rounded-dynamic border border-gray-300 bg-white shadow
3
+ my-2 p-1 flex w-full absolute z-50 shadow
4
+ rounded-dynamic border border-gray-300 bg-white
5
5
  overflow-auto [-webkit-overflow-scrolling:touch]
6
6
  focus:outline-none
7
7
  `,
8
- list: "m-1 p-0 inline-block list-none align-top w-full",
8
+ list: "list-none align-top w-full h-full",
9
9
  listItem: "group/item block",
10
10
  option: {
11
11
  base: `
12
12
  rounded px-2 py-2.5 flex items-center align-middle whitespace-nowrap cursor-pointer
13
- font-normal !leading-none normal-case text-gray-900
13
+ font-normal !leading-none text-gray-900
14
14
  hover:bg-brand-50 active:bg-brand-100
15
15
  overflow-hidden text-ellipsis
16
16
  `,
@@ -28,19 +28,8 @@ export default /*tw*/ {
28
28
  optionContent: "overflow-visible text-ellipsis",
29
29
  optionSelected: "font-bold",
30
30
  optionHighlighted: "bg-brand-50",
31
- group: {
32
- base: `pointer-events-none bg-transparent font-medium !leading-none uppercase text-gray-400 pt-4 pb-1
33
- group-first/item:pt-2`,
34
- variants: {
35
- size: {
36
- sm: "text-2xs",
37
- md: "text-xs",
38
- lg: "text-sm",
39
- },
40
- },
41
- },
42
- subGroup: {
43
- base: "pointer-events-none bg-transparent font-medium !leading-none uppercase text-gray-400 pt-2",
31
+ groupBase: {
32
+ base: "px-2 pb-2.5 font-medium !leading-none text-gray-400 overflow-hidden text-ellipsis",
44
33
  variants: {
45
34
  size: {
46
35
  sm: "text-2xs",
@@ -49,6 +38,12 @@ export default /*tw*/ {
49
38
  },
50
39
  },
51
40
  },
41
+ group: `
42
+ border-t border-gray-100 group-first/item:border-none
43
+ mt-1.5 group-first/item:mt-0
44
+ pt-4 group-first/item:pt-2
45
+ `,
46
+ subGroup: "pt-2",
52
47
  addOptionLabelWrapper: "-mb-[1.375rem] active:bg-brand-100",
53
48
  addOptionLabel: "leading-none font-medium",
54
49
  addOptionLabelHotkey: "text-gray-500",
@@ -91,12 +91,29 @@ VisibleOptions.args = { visibleOptions: 3 };
91
91
  export const WithoutOptions = DefaultTemplate.bind({});
92
92
  WithoutOptions.args = { options: [] };
93
93
 
94
+ export const GroupedOptions = DefaultTemplate.bind({});
95
+ GroupedOptions.args = {
96
+ labelKey: "name",
97
+ valueKey: "name",
98
+ options: [
99
+ { groupLabel: "Javascript" },
100
+ { name: "Vue.js" },
101
+ { name: "Adonis" },
102
+ { groupLabel: "Ruby" },
103
+ { name: "Frameworks", isSubGroup: true, level: 2 },
104
+ { name: "Rails", level: 2 },
105
+ { name: "Sinatra", level: 2 },
106
+ { groupLabel: "Other" },
107
+ { name: "Laravel" },
108
+ { name: "Phoenix" },
109
+ ],
110
+ };
111
+
94
112
  export const OptionSettings = DefaultTemplate.bind({});
95
113
  OptionSettings.args = {
96
114
  options: [
97
115
  { label: "option 1", id: "1" },
98
116
  { label: "option 2", id: "2", isHidden: true },
99
-
100
117
  {
101
118
  label: "option 3",
102
119
  id: "3",
@@ -6,7 +6,7 @@ export type OnClickOption = (option: Omit<Option, "onClick">) => void;
6
6
 
7
7
  export interface BaseOption {
8
8
  isSubGroup?: boolean;
9
- groupLabel?: boolean;
9
+ groupLabel?: string;
10
10
  level?: number;
11
11
  isHidden?: boolean;
12
12
  onClick?: OnClickOption;
@@ -12,7 +12,7 @@ export default function useAttrs(props: UDropdownListProps): UseAttrs<Config> {
12
12
  () => props.config,
13
13
  );
14
14
 
15
- const extendingKeys = ["option"];
15
+ const extendingKeys = ["option", "groupBase"];
16
16
  const extendingKeysClasses = getExtendingKeysClasses(extendingKeys);
17
17
 
18
18
  const keysAttrs = getKeysAttrs({}, [], {
@@ -20,10 +20,10 @@ export default function useAttrs(props: UDropdownListProps): UseAttrs<Config> {
20
20
  base: computed(() => [extendingKeysClasses.option.value]),
21
21
  },
22
22
  group: {
23
- base: computed(() => [extendingKeysClasses.option.value]),
23
+ base: computed(() => [extendingKeysClasses.groupBase.value]),
24
24
  },
25
25
  subGroup: {
26
- base: computed(() => [extendingKeysClasses.option.value]),
26
+ base: computed(() => [extendingKeysClasses.groupBase.value]),
27
27
  },
28
28
  });
29
29
 
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.544",
4
+ "version": "0.0.546",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
@@ -3955,8 +3955,7 @@
3955
3955
  "value": {
3956
3956
  "kind": "expression",
3957
3957
  "type": "string"
3958
- },
3959
- "default": "getDefault<UDropdownBadgeProps>(defaultConfig, UDropdownBadge).label"
3958
+ }
3960
3959
  },
3961
3960
  {
3962
3961
  "name": "options",
@@ -4191,8 +4190,7 @@
4191
4190
  "value": {
4192
4191
  "kind": "expression",
4193
4192
  "type": "string"
4194
- },
4195
- "default": "getDefault<UDropdownButtonProps>(defaultConfig, UDropdownButton).label"
4193
+ }
4196
4194
  },
4197
4195
  {
4198
4196
  "name": "options",
@@ -4461,8 +4459,7 @@
4461
4459
  "value": {
4462
4460
  "kind": "expression",
4463
4461
  "type": "string"
4464
- },
4465
- "default": "getDefault<UDropdownLinkProps>(defaultConfig, UDropdownLink).label"
4462
+ }
4466
4463
  },
4467
4464
  {
4468
4465
  "name": "options",