vueless 0.0.750 → 0.0.751

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.750",
3
+ "version": "0.0.751",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
@@ -40,8 +40,16 @@ function isSelected(option: UToggleOption) {
40
40
  return selectedValue.value === option.value;
41
41
  }
42
42
 
43
- function onClickOption(option: UToggleOption) {
44
- if (props.multiple) {
43
+ function onClickOption(rawOption: UToggleOption) {
44
+ const option = { ...rawOption };
45
+
46
+ delete option.onClick;
47
+
48
+ if (typeof rawOption.onClick === "function") {
49
+ rawOption.onClick(option);
50
+ }
51
+
52
+ if (props.multiple || props.options.length === 1) {
45
53
  const newValue = Array.isArray(selectedValue.value) ? [...selectedValue.value] : [];
46
54
  const index = newValue.indexOf(option.value);
47
55
 
@@ -105,9 +113,7 @@ const { getDataTest, optionsAttrs, toggleButtonInactiveAttrs, toggleButtonActive
105
113
  @binding {string} icon-name
106
114
  @binding {number} index
107
115
  -->
108
- <slot name="option" :option="option" :label="label" :icon-name="iconName" :index="index">
109
- {{ option.label }}
110
- </slot>
116
+ <slot name="option" :option="option" :label="label" :icon-name="iconName" :index="index" />
111
117
  </template>
112
118
 
113
119
  <template #right="{ iconName }">
@@ -6,11 +6,12 @@ export type Config = typeof defaultConfig;
6
6
 
7
7
  export interface UToggleOption {
8
8
  value: string | number;
9
- label: string;
9
+ label?: string;
10
10
  disabled?: boolean;
11
11
  icon?: string;
12
12
  leftIcon?: string;
13
13
  rightIcon?: string;
14
+ onClick?: (option: Omit<UToggleOption, "onClick">) => void;
14
15
  [key: string]: unknown;
15
16
  }
16
17