vueless 0.0.749 → 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.749",
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
 
@@ -79,7 +87,10 @@ const { getDataTest, optionsAttrs, toggleButtonInactiveAttrs, toggleButtonActive
79
87
  :round="round"
80
88
  :block="block"
81
89
  :square="square"
82
- :disabled="disabled"
90
+ :icon="option.icon"
91
+ :left-icon="option.leftIcon"
92
+ :right-icon="option.rightIcon"
93
+ :disabled="option.disabled || disabled"
83
94
  v-bind="isSelected(option) ? toggleButtonActiveAttrs : toggleButtonInactiveAttrs"
84
95
  :data-test="getDataTest(`option-${index}`)"
85
96
  @click="onClickOption(option)"
@@ -102,9 +113,7 @@ const { getDataTest, optionsAttrs, toggleButtonInactiveAttrs, toggleButtonActive
102
113
  @binding {string} icon-name
103
114
  @binding {number} index
104
115
  -->
105
- <slot name="option" :option="option" :label="label" :icon-name="iconName" :index="index">
106
- {{ option.label }}
107
- </slot>
116
+ <slot name="option" :option="option" :label="label" :icon-name="iconName" :index="index" />
108
117
  </template>
109
118
 
110
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