@witchcraft/ui 0.2.1-beta.3 → 0.2.2

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.
Files changed (203) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +20 -4
  3. package/dist/runtime/build/WitchcraftUiResolver.d.ts +2 -2
  4. package/dist/runtime/build/generateTheme.js +2 -2
  5. package/dist/runtime/components/Aria/Aria.d.vue.ts +5 -0
  6. package/dist/runtime/components/Aria/Aria.vue +4 -2
  7. package/dist/runtime/components/Aria/Aria.vue.d.ts +1 -1
  8. package/dist/runtime/components/Icon/Icon.d.vue.ts +21 -0
  9. package/dist/runtime/components/Icon/Icon.vue +3 -3
  10. package/dist/runtime/components/Icon/Icon.vue.d.ts +1 -1
  11. package/dist/runtime/components/LibButton/LibButton.d.vue.ts +36 -0
  12. package/dist/runtime/components/LibButton/LibButton.vue +9 -4
  13. package/dist/runtime/components/LibButton/LibButton.vue.d.ts +1 -1
  14. package/dist/runtime/components/LibCheckbox/LibCheckbox.d.vue.ts +42 -0
  15. package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +3 -4
  16. package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +1 -1
  17. package/dist/runtime/components/LibColorInput/LibColorInput.d.vue.ts +63 -0
  18. package/dist/runtime/components/LibColorInput/LibColorInput.vue +15 -8
  19. package/dist/runtime/components/LibColorInput/LibColorInput.vue.d.ts +1 -1
  20. package/dist/runtime/components/LibColorPicker/LibColorPicker.d.vue.ts +61 -0
  21. package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +10 -6
  22. package/dist/runtime/components/LibColorPicker/LibColorPicker.vue.d.ts +1 -1
  23. package/dist/runtime/components/LibColorPicker/utils/truncate.js +1 -1
  24. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.d.vue.ts +22 -0
  25. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +5 -2
  26. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue.d.ts +1 -1
  27. package/dist/runtime/components/LibDatePicker/LibDatePicker.d.vue.ts +40 -0
  28. package/dist/runtime/components/LibDatePicker/LibDatePicker.vue.d.ts +1 -1
  29. package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.d.vue.ts +34 -0
  30. package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue +8 -6
  31. package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue.d.ts +1 -1
  32. package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.d.vue.ts +34 -0
  33. package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +7 -5
  34. package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue.d.ts +1 -1
  35. package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.d.vue.ts +22 -0
  36. package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue.d.ts +1 -1
  37. package/dist/runtime/components/LibDebug/LibDebug.d.vue.ts +32 -0
  38. package/dist/runtime/components/LibDebug/LibDebug.vue +9 -4
  39. package/dist/runtime/components/LibDebug/LibDebug.vue.d.ts +1 -1
  40. package/dist/runtime/components/LibDevOnly/LibDevOnly.d.vue.ts +25 -0
  41. package/dist/runtime/components/LibDevOnly/LibDevOnly.vue +2 -1
  42. package/dist/runtime/components/LibDevOnly/LibDevOnly.vue.d.ts +4 -1
  43. package/dist/runtime/components/LibFileInput/LibFileInput.d.vue.ts +43 -0
  44. package/dist/runtime/components/LibFileInput/LibFileInput.vue +29 -13
  45. package/dist/runtime/components/LibFileInput/LibFileInput.vue.d.ts +2 -2
  46. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.d.vue.ts +165 -0
  47. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +42 -12
  48. package/dist/runtime/components/LibLabel/LibLabel.d.vue.ts +26 -0
  49. package/dist/runtime/components/LibLabel/LibLabel.vue +2 -2
  50. package/dist/runtime/components/LibLabel/LibLabel.vue.d.ts +3 -3
  51. package/dist/runtime/components/LibMultiValues/LibMultiValues.d.vue.ts +29 -0
  52. package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +1 -2
  53. package/dist/runtime/components/LibMultiValues/LibMultiValues.vue.d.ts +2 -2
  54. package/dist/runtime/components/LibNotifications/LibNotification.d.vue.ts +17 -0
  55. package/dist/runtime/components/LibNotifications/LibNotification.vue +19 -8
  56. package/dist/runtime/components/LibNotifications/LibNotifications.d.vue.ts +13 -0
  57. package/dist/runtime/components/LibNotifications/LibNotifications.vue +10 -6
  58. package/dist/runtime/components/LibNotifications/LibNotifications.vue.d.ts +2 -2
  59. package/dist/runtime/components/LibPagination/LibPagination.d.vue.ts +104 -0
  60. package/dist/runtime/components/LibPagination/LibPagination.vue +25 -12
  61. package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +2 -2
  62. package/dist/runtime/components/LibPalette/LibPalette.d.vue.ts +14 -0
  63. package/dist/runtime/components/LibPalette/LibPalette.vue +6 -5
  64. package/dist/runtime/components/LibPalette/LibPalette.vue.d.ts +5 -5
  65. package/dist/runtime/components/LibPopup/LibPopup.d.vue.ts +46 -0
  66. package/dist/runtime/components/LibPopup/LibPopup.vue +6 -4
  67. package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +3 -3
  68. package/dist/runtime/components/LibProgressBar/LibProgressBar.d.vue.ts +41 -0
  69. package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +5 -3
  70. package/dist/runtime/components/LibProgressBar/LibProgressBar.vue.d.ts +9 -9
  71. package/dist/runtime/components/LibRecorder/LibRecorder.d.vue.ts +77 -0
  72. package/dist/runtime/components/LibRecorder/LibRecorder.vue +1 -1
  73. package/dist/runtime/components/LibRecorder/LibRecorder.vue.d.ts +2 -2
  74. package/dist/runtime/components/LibRoot/LibRoot.d.vue.ts +41 -0
  75. package/dist/runtime/components/LibRoot/LibRoot.vue +11 -6
  76. package/dist/runtime/components/LibRoot/LibRoot.vue.d.ts +1 -1
  77. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.d.vue.ts +35 -0
  78. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue +1 -1
  79. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue.d.ts +1 -1
  80. package/dist/runtime/components/LibSuggestions/LibSuggestions.d.vue.ts +94 -0
  81. package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +6 -4
  82. package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +1 -1
  83. package/dist/runtime/components/LibTable/LibTable.d.vue.ts +45 -0
  84. package/dist/runtime/components/LibTable/LibTable.vue +23 -8
  85. package/dist/runtime/components/LibTable/LibTable.vue.d.ts +1 -1
  86. package/dist/runtime/components/Template/NAME.d.vue.ts +17 -0
  87. package/dist/runtime/components/Template/NAME.vue +2 -3
  88. package/dist/runtime/components/Template/NAME.vue.d.ts +1 -1
  89. package/dist/runtime/components/TestControls/TestControls.d.vue.ts +5 -0
  90. package/dist/runtime/components/TestControls/TestControls.vue +4 -2
  91. package/dist/runtime/components/TestControls/TestControls.vue.d.ts +1 -1
  92. package/dist/runtime/composables/useDragWithThreshold.d.ts +1 -1
  93. package/dist/runtime/composables/useInjectedI18n.d.ts +1 -1
  94. package/dist/runtime/composables/useScrollNearContainerEdges.d.ts +1 -1
  95. package/dist/runtime/composables/useSetupI18n.d.ts +1 -1
  96. package/dist/runtime/composables/useSuggestions.d.ts +2 -2
  97. package/dist/runtime/helpers/NotificationHandler.d.ts +1 -1
  98. package/dist/runtime/helpers/base64ToImg.js +2 -2
  99. package/dist/runtime/tailwind/themeConvertionOpts.d.ts +1 -1
  100. package/dist/runtime/types/index.d.ts +1 -1
  101. package/dist/runtime/utils/notifyIfError.d.ts +1 -1
  102. package/package.json +9 -10
  103. package/src/module.ts +41 -33
  104. package/src/runtime/build/WitchcraftUiResolver.ts +3 -3
  105. package/src/runtime/build/generateTheme.ts +3 -2
  106. package/src/runtime/build/unpluginIconViteOptions.ts +1 -1
  107. package/src/runtime/components/Aria/Aria.vue +5 -6
  108. package/src/runtime/components/Focus.stories.ts +11 -12
  109. package/src/runtime/components/Icon/Icon.vue +5 -9
  110. package/src/runtime/components/LibButton/LibButton.stories.ts +21 -22
  111. package/src/runtime/components/LibButton/LibButton.vue +23 -21
  112. package/src/runtime/components/LibCheckbox/LibCheckbox.stories.ts +6 -10
  113. package/src/runtime/components/LibCheckbox/LibCheckbox.vue +17 -19
  114. package/src/runtime/components/LibColorInput/LibColorInput.stories.ts +8 -13
  115. package/src/runtime/components/LibColorInput/LibColorInput.vue +49 -45
  116. package/src/runtime/components/LibColorPicker/LibColorPicker.stories.ts +14 -18
  117. package/src/runtime/components/LibColorPicker/LibColorPicker.vue +50 -52
  118. package/src/runtime/components/LibColorPicker/utils/safeConvertToHsva.ts +1 -2
  119. package/src/runtime/components/LibColorPicker/utils/safeConvertToRgba.ts +1 -2
  120. package/src/runtime/components/LibColorPicker/utils/truncate.ts +1 -2
  121. package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.ts +5 -8
  122. package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +11 -9
  123. package/src/runtime/components/LibDatePicker/LibDatePicker.stories.ts +14 -15
  124. package/src/runtime/components/LibDatePicker/LibDatePicker.vue +1 -2
  125. package/src/runtime/components/LibDatePicker/LibRangeDatePicker.vue +13 -13
  126. package/src/runtime/components/LibDatePicker/LibSingleDatePicker.vue +9 -8
  127. package/src/runtime/components/LibDatePicker/LibTimeZonePicker.vue +2 -1
  128. package/src/runtime/components/LibDatePicker/helpers.ts +0 -2
  129. package/src/runtime/components/LibDebug/LibDebug.stories.ts +11 -15
  130. package/src/runtime/components/LibDebug/LibDebug.vue +14 -11
  131. package/src/runtime/components/LibDevOnly/LibDevOnly.vue +8 -4
  132. package/src/runtime/components/LibFileInput/LibFileInput.stories.ts +12 -15
  133. package/src/runtime/components/LibFileInput/LibFileInput.vue +65 -47
  134. package/src/runtime/components/LibInputDeprecated/LibInputDeprecated.stories.ts +77 -84
  135. package/src/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +73 -48
  136. package/src/runtime/components/LibLabel/LibLabel.stories.ts +4 -8
  137. package/src/runtime/components/LibLabel/LibLabel.vue +8 -8
  138. package/src/runtime/components/LibMultiValues/LibMultiValues.stories.ts +10 -15
  139. package/src/runtime/components/LibMultiValues/LibMultiValues.vue +14 -18
  140. package/src/runtime/components/LibNotifications/LibNotification.stories.ts +30 -34
  141. package/src/runtime/components/LibNotifications/LibNotification.vue +27 -17
  142. package/src/runtime/components/LibNotifications/LibNotifications.stories.ts +11 -15
  143. package/src/runtime/components/LibNotifications/LibNotifications.vue +21 -16
  144. package/src/runtime/components/LibPagination/LibPagination.stories.ts +5 -9
  145. package/src/runtime/components/LibPagination/LibPagination.vue +46 -32
  146. package/src/runtime/components/LibPalette/LibPalette.stories.ts +3 -7
  147. package/src/runtime/components/LibPalette/LibPalette.vue +13 -12
  148. package/src/runtime/components/LibPopup/LibPopup.stories.ts +19 -23
  149. package/src/runtime/components/LibPopup/LibPopup.vue +31 -35
  150. package/src/runtime/components/LibProgressBar/LibProgressBar.stories.ts +13 -17
  151. package/src/runtime/components/LibProgressBar/LibProgressBar.vue +36 -33
  152. package/src/runtime/components/LibRecorder/LibRecorder.stories.ts +11 -12
  153. package/src/runtime/components/LibRecorder/LibRecorder.vue +34 -34
  154. package/src/runtime/components/LibRoot/LibRoot.vue +16 -12
  155. package/src/runtime/components/LibSimpleInput/LibSimpleInput.stories.ts +20 -24
  156. package/src/runtime/components/LibSimpleInput/LibSimpleInput.vue +17 -21
  157. package/src/runtime/components/LibSuggestions/LibSuggestions.stories.ts +16 -19
  158. package/src/runtime/components/LibSuggestions/LibSuggestions.vue +28 -30
  159. package/src/runtime/components/LibTable/LibTable.stories.ts +30 -33
  160. package/src/runtime/components/LibTable/LibTable.vue +38 -24
  161. package/src/runtime/components/Reset.stories.ts +3 -6
  162. package/src/runtime/components/Scrolling.stories.ts +5 -8
  163. package/src/runtime/components/Template/NAME.vue +11 -11
  164. package/src/runtime/components/Template/TemplateStory.ts +9 -10
  165. package/src/runtime/components/TestControls/TestControls.vue +5 -5
  166. package/src/runtime/components/shared/props.ts +4 -6
  167. package/src/runtime/components/shared/storyHelpers/playInput.ts +2 -3
  168. package/src/runtime/components/shared/storyHelpers/playSuggestions.ts +5 -9
  169. package/src/runtime/composables/useAccesibilityOutline.ts +1 -1
  170. package/src/runtime/composables/useAriaLabel.ts +1 -1
  171. package/src/runtime/composables/useDarkMode.ts +15 -19
  172. package/src/runtime/composables/useDragWithThreshold.ts +6 -8
  173. package/src/runtime/composables/useGlobalResizeObserver.ts +0 -1
  174. package/src/runtime/composables/useInjectedDarkMode.ts +2 -2
  175. package/src/runtime/composables/useInjectedI18n.ts +1 -1
  176. package/src/runtime/composables/useInjectedLocale.ts +3 -4
  177. package/src/runtime/composables/useScrollNearContainerEdges.stories.ts +4 -4
  178. package/src/runtime/composables/useScrollNearContainerEdges.ts +12 -13
  179. package/src/runtime/composables/useSetupI18n.ts +4 -7
  180. package/src/runtime/composables/useSetupLocale.ts +3 -5
  181. package/src/runtime/composables/useSuggestions.ts +25 -30
  182. package/src/runtime/directives/vDetectFlex.ts +5 -8
  183. package/src/runtime/directives/vExtractRootEl.ts +1 -1
  184. package/src/runtime/directives/vResizableCols.ts +3 -7
  185. package/src/runtime/directives/vResizeObserver.ts +1 -2
  186. package/src/runtime/globalResizeObserver.ts +0 -1
  187. package/src/runtime/helpers/NotificationHandler.ts +8 -12
  188. package/src/runtime/helpers/base64ToImg.ts +2 -3
  189. package/src/runtime/helpers/createNoonUtcDate.ts +0 -1
  190. package/src/runtime/helpers/defaultTranslationFunction.ts +0 -1
  191. package/src/runtime/helpers/getTimeZoneList.ts +0 -1
  192. package/src/runtime/helpers/readFile.ts +2 -2
  193. package/src/runtime/helpers/resizeObserverWrapper.ts +0 -1
  194. package/src/runtime/helpers/storybook.ts +2 -3
  195. package/src/runtime/main.lib.ts +0 -2
  196. package/src/runtime/nuxt/plugins/vue-plugin.ts +4 -5
  197. package/src/runtime/tailwind/themeConvertionOpts.ts +3 -4
  198. package/src/runtime/theme.ts +0 -1
  199. package/src/runtime/types/index.ts +3 -4
  200. package/src/runtime/utils/notifyIfError.ts +2 -2
  201. package/src/runtime/utils/twMerge.ts +2 -2
  202. package/src/runtime/vue/VueComponentsPlugin.ts +1 -2
  203. package/src/runtime/vue/registerComponents.ts +0 -1
@@ -3,22 +3,19 @@ import type { Meta, StoryObj } from "@storybook/vue3"
3
3
 
4
4
  import Label from "./LibLabel.vue"
5
5
 
6
- // eslint-disable-next-line @typescript-eslint/no-restricted-imports
7
6
  import * as components from "../index.js"
8
7
 
9
-
10
8
  const meta: Meta<typeof Label> = {
11
9
  component: Label,
12
10
  title: "Components/Label",
13
11
  args: {
14
- slot: "label",
15
- },
12
+ slot: "label"
13
+ }
16
14
  }
17
15
 
18
16
  export default meta
19
17
  type Story = StoryObj<typeof Label>
20
18
 
21
-
22
19
  export const Primary: Story = {
23
20
  render: args => ({
24
21
  components,
@@ -31,7 +28,6 @@ export const Primary: Story = {
31
28
  <lib-label v-bind="args">{{args.slot}}</lib-label>
32
29
  <lib-simple-input modelValue="some input"></lib-simple-input>
33
30
  </div>
34
- `,
35
- }),
31
+ `
32
+ })
36
33
  }
37
-
@@ -12,37 +12,37 @@
12
12
  :data-disabled="disabled"
13
13
  :data-invalid="!valid"
14
14
  :for="id"
15
- v-bind="{...$attrs, class:undefined}"
15
+ v-bind="{ ...$attrs, class: undefined }"
16
16
  >
17
17
  <slot/>
18
18
  </label>
19
19
  </template>
20
20
 
21
21
  <script setup lang="ts">
22
- import type { MakeRequired } from "@alanscodelog/utils/types"
23
- import { type LabelHTMLAttributes,toRef,useAttrs } from "vue"
22
+ import { useAttrs } from "vue"
24
23
 
25
24
  import { twMerge } from "../../utils/twMerge.js"
26
- import { type BaseInteractiveProps, getFallbackId, type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js"
27
-
25
+ import { getFallbackId } from "../shared/props.js"
28
26
 
29
27
  defineOptions({
30
- name: "lib-label",
28
+ name: "LibLabel"
31
29
  })
32
30
 
33
31
  const fallbackId = getFallbackId()
34
32
 
35
- // eslint-disable-next-line no-undef
36
33
  withDefaults(defineProps<Props>(), {
37
34
  id: "",
38
35
  valid: true,
39
- unstyle: false, disabled: false, readonly: false, border: true,
36
+ unstyle: false, disabled: false, readonly: false, border: true
40
37
  })
41
38
 
42
39
  const $attrs = useAttrs()
43
40
  </script>
44
41
 
45
42
  <script lang="ts">
43
+ import type { LabelHTMLAttributes } from "vue"
44
+ import type { BaseInteractiveProps, LabelProps, LinkableByIdProps, TailwindClassProp } from "../shared/props.js"
45
+
46
46
  type RealProps =
47
47
  & LinkableByIdProps
48
48
  & LabelProps
@@ -4,24 +4,21 @@ import { ref } from "vue"
4
4
 
5
5
  import LibMultiValues from "./LibMultiValues.vue"
6
6
 
7
- // eslint-disable-next-line @typescript-eslint/no-restricted-imports
8
7
  import * as components from "../index.js"
9
8
 
10
-
11
9
  const meta = {
12
10
  component: LibMultiValues as any,
13
11
  title: "Components/MultiValues",
14
12
  args: {
15
13
  modelValue: ["A", "B", "C"],
16
- border: true,
14
+ border: true
17
15
  },
18
- tags: ["!test"],
16
+ tags: ["!test"]
19
17
  } satisfies Meta<typeof LibMultiValues> & Meta<{ custom: string }>
20
18
 
21
19
  export default meta
22
20
  type Story = StoryObj<typeof LibMultiValues> // & StoryObj<typeof extraArgs>
23
21
 
24
-
25
22
  /**
26
23
  * The multi-value component is just the values part beneath the input.
27
24
  *
@@ -42,10 +39,9 @@ export const Primary: Story = {
42
39
  args,
43
40
  inputValue,
44
41
  multiValueEl,
45
- onKeydownEnter,
42
+ onKeydownEnter
46
43
  })
47
- }
48
- ,
44
+ },
49
45
 
50
46
  template: `
51
47
  <p>Simple Input connected to multi-value.</p>
@@ -64,21 +60,20 @@ export const Primary: Story = {
64
60
  v-model="args.modelValue"
65
61
  />
66
62
  </div>
67
- `,
68
- }),
63
+ `
64
+ })
69
65
  }
70
66
 
71
-
72
67
  export const Disabled = {
73
68
  ...Primary,
74
69
  args: {
75
- disabled: true,
76
- },
70
+ disabled: true
71
+ }
77
72
  }
78
73
 
79
74
  export const Readonly = {
80
75
  ...Primary,
81
76
  args: {
82
- readonly: true,
83
- },
77
+ readonly: true
78
+ }
84
79
  }
@@ -18,7 +18,7 @@
18
18
  :data-read-only="readonly"
19
19
  :aria-label="`Values for ${label}`"
20
20
  :tabindex="disabled ? -1 : 0"
21
- v-bind="{...$.attrs, class:undefined}"
21
+ v-bind="{ ...$.attrs, class: undefined }"
22
22
  >
23
23
  <div
24
24
  :data-border="border"
@@ -82,22 +82,20 @@ import { copy } from "../../helpers/copy.js"
82
82
  import { twMerge } from "../../utils/twMerge.js"
83
83
  import Icon from "../Icon/Icon.vue"
84
84
  import LibButton from "../LibButton/LibButton.vue"
85
- import { type BaseInteractiveProps,type LabelProps, type TailwindClassProp, type WrapperProps } from "../shared/props.js"
86
-
85
+ import type { BaseInteractiveProps, LabelProps, TailwindClassProp, WrapperProps } from "../shared/props.js"
87
86
 
88
87
  defineOptions({
89
- name: "lib-multi-values",
90
- inheritAttrs: false,
88
+ name: "LibMultiValues",
89
+ inheritAttrs: false
91
90
  })
92
91
 
93
92
  const $ = useDivideAttrs(["item"] as const)
94
93
  const props = withDefaults(defineProps<Props>(), {
95
- unstyle: false, disabled: false, readonly: false, border: true,
94
+ unstyle: false, disabled: false, readonly: false, border: true
96
95
  })
97
96
 
98
-
99
97
  const canEdit = computed(() => !props.disabled && !props.readonly)
100
- const $modelValue = defineModel<T[]>({ default: () => []})
98
+ const $modelValue = defineModel<T[]>({ default: () => [] })
101
99
 
102
100
  const removeVal = (value: T) => {
103
101
  if (!canEdit.value) return
@@ -106,22 +104,20 @@ const removeVal = (value: T) => {
106
104
  </script>
107
105
 
108
106
  <script lang="ts">
109
- type WrapperTypes = Partial<WrapperProps<"item",HTMLAttributes>>
107
+ type WrapperTypes = Partial<WrapperProps<"item", HTMLAttributes>>
110
108
 
111
- type RealProps =
112
- & LabelProps
113
- & BaseInteractiveProps
114
- & {
115
- border?: boolean
116
- }
109
+ type RealProps
110
+ = & LabelProps
111
+ & BaseInteractiveProps
112
+ & {
113
+ border?: boolean
114
+ }
117
115
  interface Props
118
116
  extends
119
117
  /** @vue-ignore */
120
- Partial<Omit<HTMLAttributes,"class"> & TailwindClassProp>,
118
+ Partial<Omit<HTMLAttributes, "class"> & TailwindClassProp>,
121
119
  /** @vue-ignore */
122
120
  WrapperTypes,
123
121
  RealProps
124
122
  {}
125
-
126
123
  </script>
127
-
@@ -4,10 +4,8 @@ import type { Meta, StoryObj } from "@storybook/vue3"
4
4
  import LibNotification from "./LibNotification.vue"
5
5
 
6
6
  import { NotificationHandler } from "../../helpers/NotificationHandler.js"
7
- // eslint-disable-next-line @typescript-eslint/no-restricted-imports
8
7
  import * as components from "../index.js"
9
8
 
10
-
11
9
  const handler = new NotificationHandler()
12
10
 
13
11
  const meta: Meta<typeof LibNotification> = {
@@ -15,13 +13,12 @@ const meta: Meta<typeof LibNotification> = {
15
13
  title: "Components/Notification",
16
14
  args: {
17
15
 
18
- },
16
+ }
19
17
  }
20
18
 
21
19
  export default meta
22
20
  type Story = StoryObj<typeof LibNotification>
23
21
 
24
-
25
22
  export const Primary: Story = {
26
23
  render: args => ({
27
24
  components: { ...components, LibNotification },
@@ -31,17 +28,17 @@ export const Primary: Story = {
31
28
  backgrounds: { disable: true },
32
29
  template: `
33
30
  <lib-notification v-bind="args"/>
34
- `,
31
+ `
35
32
  }),
36
33
  args: {
37
34
  // @ts-expect-error calling protected method
38
35
  notification: { ...handler._createEntry({
39
36
  title: `Notification`,
40
- message: `This is a notification. Pick an option:`,
37
+ message: `This is a notification. Pick an option:`
41
38
  }),
42
- // eslint-disable-next-line @typescript-eslint/no-empty-function
43
- resolve: () => { } },
44
- },
39
+
40
+ resolve: () => { } }
41
+ }
45
42
  }
46
43
  export const WithoutTitle: Story = {
47
44
  ...Primary,
@@ -50,9 +47,9 @@ export const WithoutTitle: Story = {
50
47
  // @ts-expect-error calling protected method
51
48
  notification: handler._createEntry({
52
49
  ...Primary.args!.notification,
53
- title: undefined,
54
- }),
55
- },
50
+ title: undefined
51
+ })
52
+ }
56
53
  }
57
54
  export const WithCode: Story = {
58
55
  ...Primary,
@@ -61,9 +58,9 @@ export const WithCode: Story = {
61
58
  // @ts-expect-error calling protected method
62
59
  notification: handler._createEntry({
63
60
  ...Primary.args!.notification,
64
- code: "0001",
65
- }),
66
- },
61
+ code: "0001"
62
+ })
63
+ }
67
64
  }
68
65
  export const RequiresAction: Story = {
69
66
  ...Primary,
@@ -72,9 +69,9 @@ export const RequiresAction: Story = {
72
69
  // @ts-expect-error calling protected method
73
70
  notification: handler._createEntry({
74
71
  ...Primary.args!.notification,
75
- requiresAction: true,
76
- }),
77
- },
72
+ requiresAction: true
73
+ })
74
+ }
78
75
  }
79
76
 
80
77
  /** Should not have cancel cross in top corner. */
@@ -87,9 +84,9 @@ export const Uncancellable: Story = {
87
84
  notification: handler._createEntry({
88
85
  ...Primary.args!.notification,
89
86
  options: ["Ok"],
90
- cancellable: false,
91
- }),
92
- },
87
+ cancellable: false
88
+ })
89
+ }
93
90
  }
94
91
 
95
92
  export const CustomOptions: Story = {
@@ -99,9 +96,9 @@ export const CustomOptions: Story = {
99
96
  // @ts-expect-error calling protected method
100
97
  notification: handler._createEntry({
101
98
  ...Primary.args!.notification,
102
- options: ["Ok", "Default Answer", "Cancel"],
103
- }),
104
- },
99
+ options: ["Ok", "Default Answer", "Cancel"]
100
+ })
101
+ }
105
102
  }
106
103
  export const CustomDefaultOption: Story = {
107
104
  ...Primary,
@@ -110,9 +107,9 @@ export const CustomDefaultOption: Story = {
110
107
  // @ts-expect-error calling protected method
111
108
  notification: handler._createEntry({
112
109
  ...CustomOptions.args!.notification,
113
- default: "Default Answer",
114
- }),
115
- },
110
+ default: "Default Answer"
111
+ })
112
+ }
116
113
  }
117
114
  export const CustomDangerousOption: Story = {
118
115
  ...Primary,
@@ -122,9 +119,9 @@ export const CustomDangerousOption: Story = {
122
119
  notification: handler._createEntry({
123
120
  ...CustomOptions.args!.notification,
124
121
  options: ["Ok", "Dangerous Option", "Cancel"],
125
- dangerous: ["Dangerous Option"],
126
- }),
127
- },
122
+ dangerous: ["Dangerous Option"]
123
+ })
124
+ }
128
125
  }
129
126
  export const CustomDefaultAndDangerousOption: Story = {
130
127
  ...Primary,
@@ -135,8 +132,7 @@ export const CustomDefaultAndDangerousOption: Story = {
135
132
  ...CustomOptions.args!.notification,
136
133
  options: ["Ok", "Default Answer", "Dangerous Option", "Cancel"],
137
134
  default: "Default Answer",
138
- dangerous: ["Dangerous Option"],
139
- }),
140
- },
135
+ dangerous: ["Dangerous Option"]
136
+ })
137
+ }
141
138
  }
142
-
@@ -1,5 +1,6 @@
1
1
  <template>
2
- <div :class="twMerge(`notification
2
+ <div
3
+ :class="twMerge(`notification
3
4
  max-w-700px
4
5
  bg-neutral-50
5
6
  dark:bg-neutral-900
@@ -13,14 +14,15 @@
13
14
  gap-2
14
15
  p-2 m-2
15
16
  `,
16
- ($attrs as any).class)"
17
+ ($attrs as any).class)"
17
18
  v-bind="{ ...$attrs, class: undefined }"
18
19
  tabindex="0"
19
20
  ref="notificationEl"
20
21
  @keydown.enter.self="NotificationHandler.resolveToDefault(notification)"
21
22
  >
22
23
  <div class="notification--header flex-reverse flex justify-between">
23
- <div v-if="notification.title"
24
+ <div
25
+ v-if="notification.title"
24
26
  tabindex="0"
25
27
  class="title
26
28
  focus-outline flex
@@ -32,7 +34,8 @@
32
34
  </div>
33
35
  <div class="notification--spacer flex-1"/>
34
36
  <div class="actions flex">
35
- <LibButton :border="false"
37
+ <LibButton
38
+ :border="false"
36
39
  class="notification--copy-button text-neutral-700"
37
40
  @click="copy(handler ? handler.stringify(notification) : JSON.stringify(notification))"
38
41
  >
@@ -48,21 +51,29 @@
48
51
  </lib-button>
49
52
  </div>
50
53
  </div>
51
- <div class="notification--message whitespace-pre-wrap" tabindex="0">
54
+ <div
55
+ class="notification--message whitespace-pre-wrap"
56
+ tabindex="0"
57
+ >
52
58
  {{ notification.message }}
53
59
  </div>
54
60
  <div class="notification--footer flex items-end justify-between">
55
- <div v-if="notification.code" class="code text-xs text-neutral-700 dark:text-neutral-300">
61
+ <div
62
+ v-if="notification.code"
63
+ class="code text-xs text-neutral-700 dark:text-neutral-300"
64
+ >
56
65
  Code: {{ notification.code }}
57
66
  </div>
58
67
  <div class="notification--footer-spacer flex-1 py-1"/>
59
- <div v-if="notification.options"
68
+ <div
69
+ v-if="notification.options"
60
70
  class="notification--options
61
71
  flex flex-wrap justify-end
62
72
  gap-2
63
73
  "
64
74
  >
65
- <lib-button :label="option"
75
+ <lib-button
76
+ :label="option"
66
77
  :class="twMerge(`
67
78
  notification--option-button
68
79
  `,
@@ -78,8 +89,9 @@
78
89
  </div>
79
90
  </div>
80
91
  </template>
92
+
81
93
  <script setup lang="ts">
82
- import { computed, type HTMLAttributes,ref, useAttrs } from "vue"
94
+ import { computed, type HTMLAttributes, ref, useAttrs } from "vue"
83
95
 
84
96
  import IFa6RegularCopy from "~icons/fa6-regular/copy"
85
97
  import IFa6SolidXmark from "~icons/fa6-solid/xmark"
@@ -91,30 +103,28 @@ import Icon from "../Icon/Icon.vue"
91
103
  import LibButton from "../LibButton/LibButton.vue"
92
104
  import type { TailwindClassProp } from "../shared/props.js"
93
105
 
94
-
95
106
  defineOptions({
96
- name: "lib-notification",
97
- inheritAttrs: false,
107
+ name: "LibNotification",
108
+ inheritAttrs: false
98
109
  })
99
110
  const $attrs = useAttrs()
100
111
 
101
112
  const props = withDefaults(defineProps<Props>(), {
102
- handler: undefined,
113
+ handler: undefined
103
114
  })
104
115
 
105
116
  const getColor = (notification: NotificationEntry, option: string): "ok" | "primary" | "danger" | "secondary" => notification.default === option ? "primary" : notification.dangerous.includes(option) ? "danger" : "secondary"
106
117
 
107
118
  /* Todo make this more flexible? */
108
- // eslint-disable-next-line @stylistic/space-in-parens
119
+
109
120
  const buttonColors = computed(() => props.notification.options.map((option: any /* what ??? */) => getColor(props.notification, option)))
110
121
 
111
122
  const notificationEl = ref<null | HTMLElement>(null)
112
123
  defineExpose({
113
124
  focus: () => {
114
125
  notificationEl.value?.focus()
115
- },
126
+ }
116
127
  })
117
-
118
128
  </script>
119
129
 
120
130
  <script lang="ts">
@@ -126,7 +136,7 @@ type RealProps = {
126
136
  interface Props
127
137
  extends
128
138
  /** @vue-ignore */
129
- Partial<Omit<HTMLAttributes,"class"> & TailwindClassProp>,
139
+ Partial<Omit<HTMLAttributes, "class"> & TailwindClassProp>,
130
140
  RealProps
131
141
  {}
132
142
  </script>
@@ -5,23 +5,20 @@ import { reactive, ref } from "vue"
5
5
  import LibNotifications from "./LibNotifications.vue"
6
6
 
7
7
  import { NotificationHandler } from "../../helpers/NotificationHandler.js"
8
- // eslint-disable-next-line @typescript-eslint/no-restricted-imports
9
8
  import * as components from "../index.js"
10
9
 
11
-
12
10
  const meta: Meta<typeof LibNotifications> = {
13
11
  component: LibNotifications,
14
12
  title: "Components/Notifications",
15
13
  args: {
16
14
  // @ts-expect-error story only arg
17
- withTitle: true,
18
- },
15
+ withTitle: true
16
+ }
19
17
  }
20
18
 
21
19
  export default meta
22
20
  type Story = StoryObj<typeof LibNotifications>
23
21
 
24
-
25
22
  export const Primary: Story = {
26
23
  render: args => ({
27
24
  components,
@@ -40,7 +37,7 @@ export const Primary: Story = {
40
37
  message: `This is a notification that requires action. Pick an option:`,
41
38
  requiresAction: true,
42
39
  options: ["Ok", "Default Answer", "Cancel"],
43
- default: "Default Answer",
40
+ default: "Default Answer"
44
41
  })
45
42
  }
46
43
  const notifyWithDangerousOption = () => {
@@ -50,7 +47,7 @@ export const Primary: Story = {
50
47
  message: `This is a notification that has a dangerous option. Pick an option:`,
51
48
  options: ["Ok", "Default Answer", "Dangerous Option", "Cancel"],
52
49
  default: "Default Answer",
53
- dangerous: ["Dangerous Option"],
50
+ dangerous: ["Dangerous Option"]
54
51
  })
55
52
  }
56
53
  const notifyNonCancellable = () => {
@@ -60,7 +57,7 @@ export const Primary: Story = {
60
57
  message: `This is a non-cancellable notification. Pick an option:`,
61
58
  options: ["Ok", "Default Answer"],
62
59
  default: "Default Answer",
63
- cancellable: false,
60
+ cancellable: false
64
61
  })
65
62
  }
66
63
  const notifyNonCancellableRequiresAction = () => {
@@ -71,7 +68,7 @@ export const Primary: Story = {
71
68
  requiresAction: true,
72
69
  options: ["Ok", "Default Answer"],
73
70
  default: "Default Answer",
74
- cancellable: false,
71
+ cancellable: false
75
72
  })
76
73
  }
77
74
  const notifyTimeoutable = () => {
@@ -79,7 +76,7 @@ export const Primary: Story = {
79
76
  void handler.notify({
80
77
  title: withTitle.value ? `Notification(${count})` : undefined,
81
78
  message: `This is a notification. No action required.`,
82
- timeout: disableTimeout.value ? false : 2000,
79
+ timeout: disableTimeout.value ? false : 2000
83
80
  })
84
81
  }
85
82
  return {
@@ -93,8 +90,8 @@ export const Primary: Story = {
93
90
  disableTimeout,
94
91
  args: {
95
92
  outline: false,
96
- ...args,
97
- },
93
+ ...args
94
+ }
98
95
  }
99
96
  },
100
97
  backgrounds: { disable: true },
@@ -118,7 +115,6 @@ export const Primary: Story = {
118
115
  </template>
119
116
  </lib-debug>
120
117
  </lib-root>
121
- `,
122
- }),
118
+ `
119
+ })
123
120
  }
124
-
@@ -1,5 +1,6 @@
1
1
  <template>
2
- <TransitionGroup name="list"
2
+ <TransitionGroup
3
+ name="list"
3
4
  tag="div"
4
5
  :class="twMerge(`notifications
5
6
  absolute
@@ -13,7 +14,8 @@
13
14
  `, ($attrs as any).class)"
14
15
  v-bind="{ ...$attrs, class: undefined }"
15
16
  >
16
- <lib-notification class="pointer-events-auto"
17
+ <lib-notification
18
+ class="pointer-events-auto"
17
19
  :handler="handler"
18
20
  tabindex="0"
19
21
  :notification="notification"
@@ -28,7 +30,8 @@
28
30
  />
29
31
  </Transition>
30
32
  <Transition>
31
- <dialog v-show="topNotifications.length > 0"
33
+ <dialog
34
+ v-show="topNotifications.length > 0"
32
35
  :id="id"
33
36
  :class="twMerge(`notifications-modal
34
37
  bg-transparent
@@ -40,7 +43,8 @@
40
43
  @click.self.prevent="topNotifications[0] && NotificationHandler.dismiss(topNotifications[0])"
41
44
  >
42
45
  <form>
43
- <lib-notification v-if="topNotifications.length > 0 && topNotifications[0]"
46
+ <lib-notification
47
+ v-if="topNotifications.length > 0 && topNotifications[0]"
44
48
  :handler="handler"
45
49
  class="top-notification"
46
50
  :notification="topNotifications[0]"
@@ -50,9 +54,10 @@
50
54
  </dialog>
51
55
  </Transition>
52
56
  </template>
57
+
53
58
  <script setup lang="ts">
54
59
  import { removeIfIn } from "@alanscodelog/utils/removeIfIn"
55
- import { type HTMLAttributes,nextTick, onBeforeUnmount, ref,shallowReactive, Transition, TransitionGroup } from "vue"
60
+ import { nextTick, onBeforeUnmount, ref, shallowReactive } from "vue"
56
61
 
57
62
  import LibNotification from "./LibNotification.vue"
58
63
 
@@ -62,11 +67,10 @@ import { twMerge } from "../../utils/twMerge.js"
62
67
  import type { LinkableByIdProps, TailwindClassProp } from "../shared/props.js"
63
68
 
64
69
  defineOptions({
65
- name: "lib-notifications",
66
- inheritAttrs: false,
70
+ name: "LibNotifications",
71
+ inheritAttrs: false
67
72
  })
68
73
 
69
-
70
74
  const props = defineProps<Props>()
71
75
 
72
76
  const dialogEl = ref<HTMLDialogElement | null>(null)
@@ -121,21 +125,22 @@ for (const entry of handler.queue) { addNotification(entry) }
121
125
  onBeforeUnmount(() => {
122
126
  handler.removeNotificationListener(notificationListener)
123
127
  })
124
-
125
128
  </script>
129
+
126
130
  <script lang="ts">
131
+ import type { HTMLAttributes } from "vue"
127
132
 
128
- type RealProps =
129
- & LinkableByIdProps
130
- & {
131
- /** If not provided, uses the global handler (this requires useNotificationHandler be called and configured). */
132
- handler?: NotificationHandler
133
- }
133
+ type RealProps
134
+ = & LinkableByIdProps
135
+ & {
136
+ /** If not provided, uses the global handler (this requires useNotificationHandler be called and configured). */
137
+ handler?: NotificationHandler
138
+ }
134
139
 
135
140
  interface Props
136
141
  extends
137
142
  /** @vue-ignore */
138
- Partial<Omit<HTMLAttributes,"class"> & TailwindClassProp>,
143
+ Partial<Omit<HTMLAttributes, "class"> & TailwindClassProp>,
139
144
  RealProps
140
145
  {}
141
146
  </script>