@witchcraft/ui 0.3.16 → 0.3.18

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/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "witchcraftUi",
3
3
  "configKey": "witchcraftUi",
4
- "version": "0.3.16",
4
+ "version": "0.3.18",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -97,6 +97,8 @@
97
97
  v-bind="setSlotVar('message', {
98
98
  class: `
99
99
  notification--message
100
+ shrink-1
101
+ overflow-auto
100
102
  whitespace-pre-wrap
101
103
  text-neutral-800
102
104
  dark:text-neutral-200
@@ -29,7 +29,7 @@
29
29
  :handler="handler"
30
30
  tabindex="0"
31
31
  :notification="notification"
32
- class="overflow-hidden my-2"
32
+ class="overflow-hidden my-2 max-h-[25dvh] min-h-[300px]"
33
33
  v-for="notification of notifications"
34
34
  :key="notification.id"
35
35
  @pause="handler.pause(notification)"
@@ -68,6 +68,7 @@
68
68
  class="
69
69
  data-[state=open]:animate-contentShow
70
70
  fixed
71
+ flex
71
72
  top-[50%]
72
73
  left-[50%]
73
74
  translate-x-[-50%]
@@ -79,6 +80,8 @@
79
80
  >
80
81
  <lib-notification
81
82
  class="
83
+ max-w-full
84
+ max-h-full
82
85
  top-notification
83
86
  text-md
84
87
  gap-2
@@ -177,7 +177,7 @@
177
177
  :style="{
178
178
  ...mergedVirtualizerOpts.enabled ? {
179
179
  transform: mergedVirtualizerOpts.method === 'fixed' ? `translateY(${virtual.start - index * virtual.size}px)` : `translateY(${virtual.start}px)`,
180
- height: virtual.size
180
+ height: `${virtual.size}px`
181
181
  } : {}
182
182
  }"
183
183
  :data-index="virtual.index"
@@ -287,11 +287,13 @@ function measureElement(el) {
287
287
  rowVirtualizer.value.measureElement(el);
288
288
  }
289
289
  }
290
+ let mounted = false;
290
291
  function forceRecalculateFixedVirtualizer() {
291
292
  if (mergedVirtualizerOpts.value?.method === "dynamic" || !mergedVirtualizerOpts.value.enabled) return;
292
- if (!parentRef.value) {
293
+ if (!mounted) {
293
294
  throw new Error("forceRecalculateFixedVirtualizer cannot be called before the table is mounted.");
294
295
  }
296
+ if (!parentRef.value) return;
295
297
  const height = parentRef.value.querySelector("td")?.getBoundingClientRect().height;
296
298
  if (!height) return;
297
299
  for (let i = 0; i < props.values.length; i++) {
@@ -309,7 +311,10 @@ function updateTableHeight() {
309
311
  const throttledUpdateTableHeight = throttle(updateTableHeight, 100, { leading: true });
310
312
  onMounted(() => {
311
313
  throttledUpdateTableHeight();
312
- forceRecalculateFixedVirtualizer();
314
+ mounted = true;
315
+ setTimeout(() => {
316
+ forceRecalculateFixedVirtualizer();
317
+ }, 0);
313
318
  useGlobalResizeObserver(parentRef, onResize);
314
319
  });
315
320
  const hasScrollbar = ref({ vertical: false, horizontal: false });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@witchcraft/ui",
3
- "version": "0.3.16",
3
+ "version": "0.3.18",
4
4
  "description": "Vue component library.",
5
5
  "type": "module",
6
6
  "main": "./dist/runtime/main.lib.js",
@@ -95,6 +95,8 @@
95
95
  v-bind="setSlotVar('message', {
96
96
  class: `
97
97
  notification--message
98
+ shrink-1
99
+ overflow-auto
98
100
  whitespace-pre-wrap
99
101
  text-neutral-800
100
102
  dark:text-neutral-200
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/naming-convention */
2
+ import { faker } from "@faker-js/faker"
2
3
  import type { Meta, StoryObj } from "@storybook/vue3"
3
- import { ref } from "vue"
4
+ import { computed, ref } from "vue"
4
5
 
5
6
  import LibNotifications from "./LibNotifications.vue"
6
7
 
@@ -29,22 +30,26 @@ export const Primary: Story = {
29
30
 
30
31
  const withTitle = ref(args.withTitle)
31
32
  const disableTimeout = ref(false)
33
+ const lotsOfText = ref(false)
34
+ const paragraphs = `\n Simulating lots of text:\n${faker.lorem.paragraphs(20)}`
35
+ const extraText = computed(() => lotsOfText.value ? paragraphs : "")
32
36
 
33
37
  const notifyRequiresAction = () => {
34
38
  count++
35
39
  void handler.notify({
36
40
  title: withTitle.value ? `Notification(${count})` : undefined,
37
- message: `This is a notification that requires action. Pick an option:`,
41
+ message: `This is a notification that requires action. Pick an option:${extraText.value}`,
38
42
  requiresAction: true,
39
43
  options: ["Ok", "Default Answer", "Cancel"],
40
44
  default: "Default Answer"
41
45
  })
42
46
  }
47
+
43
48
  const notifyWithDangerousOption = () => {
44
49
  count++
45
50
  void handler.notify({
46
51
  title: withTitle.value ? `Notification(${count})` : undefined,
47
- message: `This is a notification that has a dangerous option. Pick an option:`,
52
+ message: `This is a notification that has a dangerous option. Pick an option:${extraText.value}`,
48
53
  options: ["Ok", "Default Answer", "Dangerous Option", "Cancel"],
49
54
  default: "Default Answer",
50
55
  dangerous: ["Dangerous Option"]
@@ -54,7 +59,7 @@ export const Primary: Story = {
54
59
  count++
55
60
  void handler.notify({
56
61
  title: withTitle.value ? `Notification(${count})` : undefined,
57
- message: `This is a non-cancellable notification. Pick an option:`,
62
+ message: `This is a non-cancellable notification. Pick an option:${extraText.value}`,
58
63
  options: ["Ok", "Default Answer"],
59
64
  default: "Default Answer",
60
65
  cancellable: false
@@ -64,7 +69,7 @@ export const Primary: Story = {
64
69
  count++
65
70
  void handler.notify({
66
71
  title: withTitle.value ? `Notification(${count})` : undefined,
67
- message: `This is a non-cancellable notification. Pick an option:`,
72
+ message: `This is a non-cancellable notification. Pick an option:${extraText.value}`,
68
73
  requiresAction: true,
69
74
  options: ["Ok", "Default Answer"],
70
75
  default: "Default Answer",
@@ -75,7 +80,7 @@ export const Primary: Story = {
75
80
  count++
76
81
  void handler.notify({
77
82
  title: withTitle.value ? `Notification(${count})` : undefined,
78
- message: `This is a notification. No action required.`,
83
+ message: `This is a notification. No action required.${extraText.value}`,
79
84
  timeout: disableTimeout.value ? false : 5000
80
85
  })
81
86
  }
@@ -88,6 +93,7 @@ export const Primary: Story = {
88
93
  handler,
89
94
  withTitle,
90
95
  disableTimeout,
96
+ lotsOfText,
91
97
  args: {
92
98
  outline: false,
93
99
  ...args
@@ -103,9 +109,10 @@ export const Primary: Story = {
103
109
  <lib-button :label="'Notify Non-Cancellable that RequiresAction'" @click="notifyNonCancellableRequiresAction()"></lib-button>
104
110
  <lib-button :label="'Notify With Dangerous Option'" @click="notifyWithDangerousOption()"></lib-button>
105
111
  <lib-button :label="'Notify Non-Cancellable'" @click="notifyNonCancellable()"></lib-button>
106
- <input type="checkbox" v-model="withTitle"/> With Title
107
- <input type="checkbox" v-model="disableTimeout"/> Disable Timeout
108
- <lib-notifications :handler="handler" />
112
+ <lib-checkbox v-model="lotsOfText">Use lots of text</lib-checkbox>
113
+ <lib-checkbox v-model="disableTimeout">Disable Timeout</lib-checkbox>
114
+ <lib-checkbox v-model="withTitle">With Title</lib-checkbox>
115
+ <lib-notifications :handler="handler" />
109
116
  History:
110
117
  <lib-debug>
111
118
  <template v-for="entry in handler.history">
@@ -29,7 +29,7 @@
29
29
  :handler="handler"
30
30
  tabindex="0"
31
31
  :notification="notification"
32
- class="overflow-hidden my-2"
32
+ class="overflow-hidden my-2 max-h-[25dvh] min-h-[300px]"
33
33
  v-for="notification of notifications"
34
34
  :key="notification.id"
35
35
  @pause="handler.pause(notification)"
@@ -68,6 +68,7 @@
68
68
  class="
69
69
  data-[state=open]:animate-contentShow
70
70
  fixed
71
+ flex
71
72
  top-[50%]
72
73
  left-[50%]
73
74
  translate-x-[-50%]
@@ -79,6 +80,8 @@
79
80
  >
80
81
  <lib-notification
81
82
  class="
83
+ max-w-full
84
+ max-h-full
82
85
  top-notification
83
86
  text-md
84
87
  gap-2
@@ -182,7 +182,7 @@
182
182
  transform: mergedVirtualizerOpts.method === 'fixed'
183
183
  ? `translateY(${virtual.start - index * virtual.size!}px)`
184
184
  : `translateY(${virtual.start}px)`,
185
- height: virtual.size
185
+ height: `${virtual.size}px`
186
186
  }
187
187
  : {})
188
188
  }"
@@ -314,11 +314,13 @@ function measureElement(el: any): void {
314
314
  }
315
315
  }
316
316
 
317
+ let mounted = false
317
318
  function forceRecalculateFixedVirtualizer() {
318
319
  if (mergedVirtualizerOpts.value?.method === "dynamic" || !mergedVirtualizerOpts.value.enabled) return
319
- if (!parentRef.value) {
320
+ if (!mounted) {
320
321
  throw new Error("forceRecalculateFixedVirtualizer cannot be called before the table is mounted.")
321
322
  }
323
+ if (!parentRef.value) return // this could happen if the table is destroyed before the timeout (highly unlikely, probably impossible)
322
324
  const height = parentRef.value.querySelector("td")?.getBoundingClientRect().height
323
325
  if (!height) return
324
326
  for (let i = 0; i < props.values.length; i++) {
@@ -339,7 +341,10 @@ const throttledUpdateTableHeight = throttle(updateTableHeight, 100, { leading: t
339
341
 
340
342
  onMounted(() => {
341
343
  throttledUpdateTableHeight()
342
- forceRecalculateFixedVirtualizer()
344
+ mounted = true
345
+ setTimeout(() => {
346
+ forceRecalculateFixedVirtualizer()
347
+ }, 0)
343
348
  useGlobalResizeObserver(parentRef, onResize)
344
349
  })
345
350