@pequity/squirrel 7.0.1 → 7.0.3

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,7 +11,7 @@ const _hoisted_2 = { class: "whitespace-nowrap px-3" };
11
11
  const _hoisted_3 = { class: "flex" };
12
12
  const _hoisted_4 = { class: "flex items-center gap-2 px-1 py-0.5" };
13
13
  const _hoisted_5 = { class: "flex items-center gap-2 px-1 py-0.5" };
14
- const _hoisted_6 = { class: "flex flex-col bg-p-purple-60" };
14
+ const _hoisted_6 = { class: "bg-p-purple-60 py-2" };
15
15
  const _hoisted_7 = { class: "flex items-center gap-2 px-1 py-0.5" };
16
16
  const _sfc_main = /* @__PURE__ */ vue.defineComponent({
17
17
  ...{
@@ -72,17 +72,17 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
72
72
  placement: "top",
73
73
  strategy: "fixed"
74
74
  }, {
75
- popper: vue.withCtx(() => [
76
- vue.createElementVNode("div", _hoisted_6, [
75
+ popper: vue.withCtx(({ hide }) => [
76
+ vue.createElementVNode("ul", _hoisted_6, [
77
77
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(actionOrMenu.subActions, (subaction) => {
78
- return vue.openBlock(), vue.createElementBlock("div", {
78
+ return vue.openBlock(), vue.createElementBlock("li", {
79
79
  key: `subaction-${subaction.name}`
80
80
  }, [
81
81
  vue.createVNode(pBtn_vue_vue_type_script_setup_true_lang._sfc_main, {
82
82
  size: "sm",
83
- class: "w-full",
83
+ class: "w-full [&>.items-center]:justify-start",
84
84
  type: "secondary-ghost-dark",
85
- onClick: ($event) => _ctx.$emit("click:action", subaction.name)
85
+ onClick: ($event) => (_ctx.$emit("click:action", subaction.name), hide())
86
86
  }, {
87
87
  default: vue.withCtx(() => [
88
88
  vue.createElementVNode("div", _hoisted_7, [
@@ -420,7 +420,9 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
420
420
  }, [
421
421
  vue.createVNode(pIcon_vue_vue_type_script_setup_true_lang._sfc_main, { icon: "fe:plus-circle" }),
422
422
  vue.createTextVNode(" Add '" + vue.toDisplayString(vue.unref(search)) + "' ", 1)
423
- ])) : (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
423
+ ])) : __props.creatable ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
424
+ vue.createTextVNode("No items found. Type to add")
425
+ ], 64)) : (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
424
426
  vue.createTextVNode("No items found")
425
427
  ], 64))
426
428
  ], 2)
@@ -10,7 +10,7 @@ const _hoisted_2 = { class: "whitespace-nowrap px-3" };
10
10
  const _hoisted_3 = { class: "flex" };
11
11
  const _hoisted_4 = { class: "flex items-center gap-2 px-1 py-0.5" };
12
12
  const _hoisted_5 = { class: "flex items-center gap-2 px-1 py-0.5" };
13
- const _hoisted_6 = { class: "flex flex-col bg-p-purple-60" };
13
+ const _hoisted_6 = { class: "bg-p-purple-60 py-2" };
14
14
  const _hoisted_7 = { class: "flex items-center gap-2 px-1 py-0.5" };
15
15
  const _sfc_main = /* @__PURE__ */ defineComponent({
16
16
  ...{
@@ -71,17 +71,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
71
71
  placement: "top",
72
72
  strategy: "fixed"
73
73
  }, {
74
- popper: withCtx(() => [
75
- createElementVNode("div", _hoisted_6, [
74
+ popper: withCtx(({ hide }) => [
75
+ createElementVNode("ul", _hoisted_6, [
76
76
  (openBlock(true), createElementBlock(Fragment, null, renderList(actionOrMenu.subActions, (subaction) => {
77
- return openBlock(), createElementBlock("div", {
77
+ return openBlock(), createElementBlock("li", {
78
78
  key: `subaction-${subaction.name}`
79
79
  }, [
80
80
  createVNode(_sfc_main$1, {
81
81
  size: "sm",
82
- class: "w-full",
82
+ class: "w-full [&>.items-center]:justify-start",
83
83
  type: "secondary-ghost-dark",
84
- onClick: ($event) => _ctx.$emit("click:action", subaction.name)
84
+ onClick: ($event) => (_ctx.$emit("click:action", subaction.name), hide())
85
85
  }, {
86
86
  default: withCtx(() => [
87
87
  createElementVNode("div", _hoisted_7, [
@@ -419,7 +419,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
419
419
  }, [
420
420
  createVNode(_sfc_main$1, { icon: "fe:plus-circle" }),
421
421
  createTextVNode(" Add '" + toDisplayString(unref(search)) + "' ", 1)
422
- ])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
422
+ ])) : __props.creatable ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
423
+ createTextVNode("No items found. Type to add")
424
+ ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 2 }, [
423
425
  createTextVNode("No items found")
424
426
  ], 64))
425
427
  ], 2)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pequity/squirrel",
3
3
  "description": "Squirrel component library",
4
- "version": "7.0.1",
4
+ "version": "7.0.3",
5
5
  "packageManager": "pnpm@9.15.9",
6
6
  "type": "module",
7
7
  "scripts": {
@@ -24,12 +24,16 @@ const createPDropdownStub = () => {
24
24
  toggleShow() {
25
25
  this.show = !this.show;
26
26
  },
27
+
28
+ hide() {
29
+ this.show = false;
30
+ },
27
31
  },
28
32
  template: `
29
33
  <div class="p-dropdown-stub">
30
34
  <slot></slot>
31
35
  <div v-if="show" class="p-dropdown-stub-popper">
32
- <slot name="popper"></slot>
36
+ <slot name="popper" :hide="hide"></slot>
33
37
  </div>
34
38
  </div>`,
35
39
  });
@@ -29,14 +29,14 @@
29
29
  <div>{{ actionOrMenu.label }}</div>
30
30
  </div>
31
31
  </PBtn>
32
- <template #popper>
33
- <div class="flex flex-col bg-p-purple-60">
34
- <div v-for="subaction in actionOrMenu.subActions" :key="`subaction-${subaction.name}`">
32
+ <template #popper="{ hide }">
33
+ <ul class="bg-p-purple-60 py-2">
34
+ <li v-for="subaction in actionOrMenu.subActions" :key="`subaction-${subaction.name}`">
35
35
  <PBtn
36
36
  size="sm"
37
- class="w-full"
37
+ class="w-full [&>.items-center]:justify-start"
38
38
  type="secondary-ghost-dark"
39
- @click="$emit('click:action', subaction.name)"
39
+ @click="($emit('click:action', subaction.name), hide())"
40
40
  >
41
41
  <div class="flex items-center gap-2 px-1 py-0.5">
42
42
  <Component :is="subaction.icon" v-if="isComponent(subaction.icon)" class="h-4 w-4" />
@@ -44,8 +44,8 @@
44
44
  <div>{{ subaction.label }}</div>
45
45
  </div>
46
46
  </PBtn>
47
- </div>
48
- </div>
47
+ </li>
48
+ </ul>
49
49
  </template>
50
50
  </PDropdown>
51
51
  </template>
@@ -764,6 +764,16 @@ describe('PDropdownSelect.vue', () => {
764
764
  cleanup(wrapper);
765
765
  });
766
766
 
767
+ it('shows "Type to add" message when creatable is true and no search term', async () => {
768
+ useVirtualizer.mockImplementation(() => createMockedVirtualizer(0));
769
+ const wrapper = createWrapper({ selected: null, items: [] }, { searchable: true, creatable: true });
770
+ await wrapper.find('button').trigger('click');
771
+ await sleep(200);
772
+ const noItemsMessage = wrapper.find('div.flex.items-center.justify-center.h-10.text-base');
773
+ expect(noItemsMessage.text()).toBe('No items found. Type to add');
774
+ cleanup(wrapper);
775
+ });
776
+
767
777
  it('does not show create option when creatable is false', async () => {
768
778
  useVirtualizer.mockImplementation(() => createMockedVirtualizer(20));
769
779
  const wrapper = createWrapper({ selected: null }, { searchable: true, creatable: false });
@@ -160,6 +160,7 @@
160
160
  Add '{{ search }}'
161
161
  </button>
162
162
  </template>
163
+ <template v-else-if="creatable">No items found. Type to add</template>
163
164
  <template v-else>No items found</template>
164
165
  </div>
165
166
  </slot>