@pequity/squirrel 6.0.4 → 6.0.6

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.
@@ -11,10 +11,7 @@ const text = require("../text.js");
11
11
  const lodashEs = require("lodash-es");
12
12
  const _imports_0 = "data:image/svg+xml,%3csvg%20width='18'%20height='12'%20viewBox='0%200%2018%2012'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M16.1383%200.166992L6.30411%209.83366L1.69828%205.27533L0.526611%206.46033L5.71578%2011.597C5.87174%2011.7509%206.08205%2011.8372%206.3012%2011.8372C6.52034%2011.8372%206.73065%2011.7509%206.88661%2011.597L17.3033%201.35366L16.1383%200.166992Z'%20fill='%231A123B'%20/%3e%3c/svg%3e";
13
13
  const _hoisted_1 = ["data-has-error"];
14
- const _hoisted_2 = {
15
- key: 0,
16
- class: "truncate text-left text-p-gray-40"
17
- };
14
+ const _hoisted_2 = { class: "truncate text-left text-p-gray-40" };
18
15
  const _hoisted_3 = { class: "truncate text-left" };
19
16
  const _hoisted_4 = {
20
17
  key: 0,
@@ -415,7 +412,9 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
415
412
  "aria-haspopup": "listbox",
416
413
  onClick: _cache[1] || (_cache[1] = ($event) => dropdownShow.value = !dropdownShow.value)
417
414
  }), [
418
- !vue.unref(internalValue).length || !vue.unref(selectedItems).length ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2, vue.toDisplayString(__props.placeholder || " "), 1)) : vue.renderSlot(_ctx.$slots, "selected-item", {
415
+ !vue.unref(internalValue).length || !vue.unref(selectedItems).length ? vue.renderSlot(_ctx.$slots, "placeholder", { key: 0 }, () => [
416
+ vue.createElementVNode("div", _hoisted_2, vue.toDisplayString(__props.placeholder || " "), 1)
417
+ ]) : vue.renderSlot(_ctx.$slots, "selected-item", {
419
418
  key: 1,
420
419
  item: __props.multiple ? vue.unref(selectedItems) : vue.unref(selectedItems)[0]
421
420
  }, () => [
@@ -71,9 +71,9 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
71
71
  type: "secondary-outline-blue",
72
72
  disabled: item.disabled,
73
73
  class: vue.normalizeClass({
74
- "rounded-none": index !== 0 && index !== _ctx.items.length - 1,
75
- "rounded-br-none rounded-tr-none": index === 0,
76
- "rounded-bl-none rounded-tl-none": index === _ctx.items.length - 1,
74
+ "rounded-none": index !== 0 && index !== _ctx.items.length - 1 && _ctx.items.length > 1,
75
+ "rounded-br-none rounded-tr-none": index === 0 && _ctx.items.length > 1,
76
+ "rounded-bl-none rounded-tl-none": index === _ctx.items.length - 1 && _ctx.items.length > 1,
77
77
  "-mr-0.5": index !== _ctx.items.length - 1,
78
78
  "flex-1": _ctx.grow
79
79
  }),
@@ -10,10 +10,7 @@ import { splitStringForHighlight } from "../text.js";
10
10
  import { omit } from "lodash-es";
11
11
  const _imports_0 = "data:image/svg+xml,%3csvg%20width='18'%20height='12'%20viewBox='0%200%2018%2012'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M16.1383%200.166992L6.30411%209.83366L1.69828%205.27533L0.526611%206.46033L5.71578%2011.597C5.87174%2011.7509%206.08205%2011.8372%206.3012%2011.8372C6.52034%2011.8372%206.73065%2011.7509%206.88661%2011.597L17.3033%201.35366L16.1383%200.166992Z'%20fill='%231A123B'%20/%3e%3c/svg%3e";
12
12
  const _hoisted_1 = ["data-has-error"];
13
- const _hoisted_2 = {
14
- key: 0,
15
- class: "truncate text-left text-p-gray-40"
16
- };
13
+ const _hoisted_2 = { class: "truncate text-left text-p-gray-40" };
17
14
  const _hoisted_3 = { class: "truncate text-left" };
18
15
  const _hoisted_4 = {
19
16
  key: 0,
@@ -414,7 +411,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
414
411
  "aria-haspopup": "listbox",
415
412
  onClick: _cache[1] || (_cache[1] = ($event) => dropdownShow.value = !dropdownShow.value)
416
413
  }), [
417
- !unref(internalValue).length || !unref(selectedItems).length ? (openBlock(), createElementBlock("div", _hoisted_2, toDisplayString(__props.placeholder || " "), 1)) : renderSlot(_ctx.$slots, "selected-item", {
414
+ !unref(internalValue).length || !unref(selectedItems).length ? renderSlot(_ctx.$slots, "placeholder", { key: 0 }, () => [
415
+ createElementVNode("div", _hoisted_2, toDisplayString(__props.placeholder || " "), 1)
416
+ ]) : renderSlot(_ctx.$slots, "selected-item", {
418
417
  key: 1,
419
418
  item: __props.multiple ? unref(selectedItems) : unref(selectedItems)[0]
420
419
  }, () => [
@@ -70,9 +70,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
70
70
  type: "secondary-outline-blue",
71
71
  disabled: item.disabled,
72
72
  class: normalizeClass({
73
- "rounded-none": index !== 0 && index !== _ctx.items.length - 1,
74
- "rounded-br-none rounded-tr-none": index === 0,
75
- "rounded-bl-none rounded-tl-none": index === _ctx.items.length - 1,
73
+ "rounded-none": index !== 0 && index !== _ctx.items.length - 1 && _ctx.items.length > 1,
74
+ "rounded-br-none rounded-tr-none": index === 0 && _ctx.items.length > 1,
75
+ "rounded-bl-none rounded-tl-none": index === _ctx.items.length - 1 && _ctx.items.length > 1,
76
76
  "-mr-0.5": index !== _ctx.items.length - 1,
77
77
  "flex-1": _ctx.grow
78
78
  }),
@@ -8,6 +8,7 @@ declare function __VLS_template(): {
8
8
  'selected-item'(props: {
9
9
  item: any;
10
10
  }): unknown;
11
+ placeholder(): unknown;
11
12
  'no-items'(): unknown;
12
13
  item(props: {
13
14
  item: any;
@@ -18,6 +19,7 @@ declare function __VLS_template(): {
18
19
  'selected-item'(props: {
19
20
  item: any;
20
21
  }): unknown;
22
+ placeholder(): unknown;
21
23
  'no-items'(): unknown;
22
24
  item(props: {
23
25
  item: any;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pequity/squirrel",
3
3
  "description": "Squirrel component library",
4
- "version": "6.0.4",
4
+ "version": "6.0.6",
5
5
  "packageManager": "pnpm@9.15.3",
6
6
  "type": "module",
7
7
  "scripts": {
@@ -24,9 +24,11 @@
24
24
  aria-haspopup="listbox"
25
25
  @click="dropdownShow = !dropdownShow"
26
26
  >
27
- <div v-if="!internalValue.length || !selectedItems.length" class="truncate text-left text-p-gray-40">
28
- {{ placeholder || '&nbsp;' }}
29
- </div>
27
+ <slot v-if="!internalValue.length || !selectedItems.length" name="placeholder">
28
+ <div class="truncate text-left text-p-gray-40">
29
+ {{ placeholder || '&nbsp;' }}
30
+ </div>
31
+ </slot>
30
32
  <slot v-else name="selected-item" :item="multiple ? selectedItems : selectedItems[0]">
31
33
  <div class="truncate text-left">
32
34
  {{
@@ -189,6 +191,7 @@ defineOptions({
189
191
  defineSlots<{
190
192
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
191
193
  'selected-item'(props: { item: any }): unknown;
194
+ 'placeholder'(): unknown;
192
195
  'no-items'(): unknown;
193
196
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
194
197
  item(props: { item: any; isItemSelected: boolean; itemTextSplit: string[] }): unknown;
@@ -176,6 +176,24 @@ describe('PSelectBtn.vue', () => {
176
176
  });
177
177
  });
178
178
 
179
+ it('does not add rounded classes when there is only one item', async () => {
180
+ const singleItem = [{ textCustom: 'Option 1', valueCustom: 1 }];
181
+ const wrapper = createWrapperFor(PSelectBtn, {
182
+ props: {
183
+ items: singleItem,
184
+ itemValue: 'valueCustom',
185
+ itemText: 'textCustom',
186
+ modelValue: 1,
187
+ },
188
+ });
189
+
190
+ const button = await wrapper.find('button');
191
+ const roundedClasses = ['rounded-none', 'rounded-br-none', 'rounded-tr-none', 'rounded-bl-none', 'rounded-tl-none'];
192
+ roundedClasses.forEach((className) => {
193
+ expect(button.classes()).not.toContain(className);
194
+ });
195
+ });
196
+
179
197
  it('renders full-width buttons', async () => {
180
198
  const wrapper = createWrapperFor(PSelectBtn, {
181
199
  props: {
@@ -11,9 +11,9 @@
11
11
  type="secondary-outline-blue"
12
12
  :disabled="item.disabled"
13
13
  :class="{
14
- 'rounded-none': index !== 0 && index !== items.length - 1,
15
- 'rounded-br-none rounded-tr-none': index === 0,
16
- 'rounded-bl-none rounded-tl-none': index === items.length - 1,
14
+ 'rounded-none': index !== 0 && index !== items.length - 1 && items.length > 1,
15
+ 'rounded-br-none rounded-tr-none': index === 0 && items.length > 1,
16
+ 'rounded-bl-none rounded-tl-none': index === items.length - 1 && items.length > 1,
17
17
  '-mr-0.5': index !== items.length - 1,
18
18
  'flex-1': grow,
19
19
  }"