@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
@@ -5,7 +5,6 @@ import type { ComponentExposed } from "vue-component-type-helpers"
5
5
 
6
6
  import LibSuggestions from "./LibSuggestions.vue"
7
7
 
8
- // eslint-disable-next-line @typescript-eslint/no-restricted-imports
9
8
  import * as components from "../index.js"
10
9
 
11
10
  const meta = {
@@ -16,8 +15,8 @@ const meta = {
16
15
  modelValue: "",
17
16
  label: "Some Label",
18
17
  border: true,
19
- suggestions: ["A", "AB", "ABC", "B", "BC", "C", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"],
20
- },
18
+ suggestions: ["A", "AB", "ABC", "B", "BC", "C", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
19
+ }
21
20
  } // satisfies Meta<typeof LibSuggestions> & Meta<{ custom: string }>
22
21
 
23
22
  export default meta
@@ -33,7 +32,7 @@ type Story = StoryObj<typeof LibSuggestions> // & StoryObj<typeof extraArgs>
33
32
  export const Primary: Story = {
34
33
  render: args => ({
35
34
  components: { ...components, LibSuggestions },
36
-
35
+
37
36
  setup: () => {
38
37
  const inputValue = ref(args.modelValue)
39
38
  const modelValue = ref(args.modelValue)
@@ -56,7 +55,7 @@ export const Primary: Story = {
56
55
  suggestions,
57
56
  drawer,
58
57
  keydownHandler,
59
- blurHandler,
58
+ blurHandler
60
59
  }
61
60
  },
62
61
 
@@ -88,26 +87,25 @@ export const Primary: Story = {
88
87
  </template>
89
88
  </lib-suggestions>
90
89
  </div>
91
- `,
92
- }),
90
+ `
91
+ })
93
92
  }
94
93
 
95
94
  export const RestrictToSuggestions: Story = {
96
95
  ...Primary,
97
96
  args: {
98
97
  ...Primary.args,
99
- restrictToSuggestions: true,
100
- },
101
-
102
-
98
+ restrictToSuggestions: true
99
+ }
100
+
103
101
  }
104
102
  export const AlwaysShowAllSuggestions = {
105
103
  ...Primary,
106
104
  args: {
107
105
  ...Primary.args,
108
106
  restrictToSuggestions: true,
109
- suggestionsFilter: (_input: string, items: string[]) => items,
110
- },
107
+ suggestionsFilter: (_input: string, items: string[]) => items
108
+ }
111
109
 
112
110
  }
113
111
  export const AlwaysShowAllSuggestionsAndNoRestrictToSuggestions = {
@@ -115,8 +113,8 @@ export const AlwaysShowAllSuggestionsAndNoRestrictToSuggestions = {
115
113
  args: {
116
114
  ...Primary.args,
117
115
  restrictToSuggestions: false,
118
- suggestionsFilter: (_input: string, items: string[]) => items,
119
- },
116
+ suggestionsFilter: (_input: string, items: string[]) => items
117
+ }
120
118
 
121
119
  }
122
120
  export const CustomSuggestionsObject = {
@@ -128,10 +126,9 @@ export const CustomSuggestionsObject = {
128
126
  { label: "A", other: "some data A" },
129
127
  { label: "AB", other: "some data AB" },
130
128
  { label: "ABC", other: "some data ABC" },
131
- { label: "ABCDEFGHIJKLMNOPQRSTUVWXYZ", other: "some data ABCDEFGHIJKLMNOPQRSTUVWXYZ" },
129
+ { label: "ABCDEFGHIJKLMNOPQRSTUVWXYZ", other: "some data ABCDEFGHIJKLMNOPQRSTUVWXYZ" }
132
130
  ],
133
- suggestionLabel: (item: any) => item.label,
134
- },
131
+ suggestionLabel: (item: any) => item.label
132
+ }
135
133
 
136
134
  }
137
-
@@ -13,10 +13,11 @@
13
13
  :data-open="$open"
14
14
  role="listbox"
15
15
  ref="el"
16
- v-bind="{...$.attrs, class:undefined}"
16
+ v-bind="{ ...$.attrs, class: undefined }"
17
17
  >
18
18
  <!-- Click event is just in case, it should not really be triggered. We can do click selections via the blur handler. -->
19
- <div :id="`suggestion-${id ?? fallbackId}-${index}`"
19
+ <div
20
+ :id="`suggestion-${id ?? fallbackId}-${index}`"
20
21
  role="option"
21
22
  :class="twMerge(`
22
23
  suggestions--item
@@ -30,7 +31,7 @@
30
31
  `,
31
32
  ($.itemAttrs as any)?.class
32
33
  )"
33
- v-bind="{...$.itemAttrs, class:undefined}"
34
+ v-bind="{ ...$.itemAttrs, class: undefined }"
34
35
  :aria-selected="index === suggestions.active ? true : false"
35
36
  :aria-label="suggestions.getLabel(item)"
36
37
  v-for="(item, index) in suggestions.filtered"
@@ -39,7 +40,8 @@
39
40
  @mousedown.prevent
40
41
  @mouseup="suggestions.enterIndex(index, !Array.isArray($modelValue))"
41
42
  >
42
- <slot name="item"
43
+ <slot
44
+ name="item"
43
45
  :item="item"
44
46
  :index="index"
45
47
  :is-selected="Array.isArray($modelValue) ? $modelValue.includes(item) : $modelValue === item"
@@ -57,21 +59,19 @@
57
59
  </div>
58
60
  </template>
59
61
 
60
-
61
62
  <script setup lang="ts" generic="TSuggestion extends string | object, TValue extends string|string[]">
62
-
63
- import { type HTMLAttributes,reactive, ref } from "vue"
63
+ import { type HTMLAttributes, reactive, ref } from "vue"
64
64
 
65
65
  import { useDivideAttrs } from "../../composables/useDivideAttrs.js"
66
66
  import { useSuggestions } from "../../composables/useSuggestions.js"
67
67
  import { hasModifiers } from "../../helpers/hasModifiers.js"
68
68
  import { twMerge } from "../../utils/twMerge.js"
69
69
  import LibCheckbox from "../LibCheckbox/LibCheckbox.vue"
70
- import { type BaseInteractiveProps, getFallbackId,type LabelProps, type LinkableByIdProps, type SuggestionsEmits, type SuggestionsProps, type WrapperProps } from "../shared/props.js"
70
+ import { type BaseInteractiveProps, getFallbackId, type LabelProps, type LinkableByIdProps, type SuggestionsEmits, type SuggestionsProps, type WrapperProps } from "../shared/props.js"
71
71
 
72
72
  defineOptions({
73
- name: "lib-suggestions",
74
- inheritAttrs: false,
73
+ name: "LibSuggestions",
74
+ inheritAttrs: false
75
75
  })
76
76
 
77
77
  const $ = useDivideAttrs(["item"] as const)
@@ -82,8 +82,9 @@ const fallbackId = getFallbackId()
82
82
  const props = withDefaults(defineProps<Props & SuggestionsProps<TSuggestion>>(), {
83
83
  isValid: true,
84
84
  canOpen: true,
85
+ canClose: true,
85
86
  filterKeydown: undefined,
86
- unstyle: false, disabled: false, readonly: false, border: true,
87
+ unstyle: false, disabled: false, readonly: false, border: true
87
88
  })
88
89
  /**
89
90
  * The final valid value. This is *not* the value you want to share with the input. If `restrictToSuggestions` is true this will not update on any invalid values that `inputValue` might be set to.
@@ -96,11 +97,10 @@ const $modelValue = defineModel<TValue>("modelValue", { required: true })
96
97
  *
97
98
  * It allows the component to read even invalid output, and also to reset that invalid output when either modelValue is set to a new value, or when the component is closed via cancel.
98
99
  */
99
- const $inputValue = defineModel<string >("inputValue", { default: "" })
100
+ const $inputValue = defineModel<string>("inputValue", { default: "" })
100
101
 
101
102
  const $open = defineModel<boolean>("open", { default: false })
102
103
 
103
-
104
104
  if (typeof props.suggestions?.[0] === "object" && !props.suggestionLabel && !props.suggestionsFilter) {
105
105
  throw new Error("`suggestionLabel` or `suggestionsFilter` must be passed if suggestions are objects.")
106
106
  }
@@ -148,7 +148,7 @@ const inputKeydownHandler = (e: KeyboardEvent): void => {
148
148
  }
149
149
  const inputBlurHandler = (e: MouseEvent): void => {
150
150
  if (props.filterBlur?.(e)) return
151
-
151
+
152
152
  if (!$open.value) return
153
153
 
154
154
  if (props.restrictToSuggestions) {
@@ -175,34 +175,33 @@ defineExpose({
175
175
  /** A blur handler for the input that controls the component. This also takes care of making clicking on a suggestion work, since otherwise if canOpen is set to false in the blur handler, no click event will fire. */
176
176
  inputBlurHandler,
177
177
  /** A focus handler for the input that controls the component. */
178
- inputFocusHandler,
178
+ inputFocusHandler
179
179
  })
180
-
181
180
  </script>
182
181
 
183
182
  <script lang="ts">
184
- type WrapperTypes = Partial<WrapperProps<"item",HTMLAttributes, {
183
+ type WrapperTypes = Partial<WrapperProps<"item", HTMLAttributes, {
185
184
  /** Tailwind classes. */
186
185
  class?: string
187
186
  }>>
188
187
 
189
- type RealProps =
190
- & LinkableByIdProps
191
- & LabelProps
192
- & BaseInteractiveProps
193
- & {
188
+ type RealProps
189
+ = & LinkableByIdProps
190
+ & LabelProps
191
+ & BaseInteractiveProps
192
+ & {
194
193
  /** Return true to prevent the keydown event from being handled. */
195
- filterKeydown?: (e: KeyboardEvent) => boolean
196
- /** Return true to prevent the blur event from being handled. */
197
- filterBlur?: (e: MouseEvent) => boolean
198
- /** Return true to prevent the focus event from being handled. */
199
- filterFocus?: (e: FocusEvent) => boolean
200
- }
194
+ filterKeydown?: (e: KeyboardEvent) => boolean
195
+ /** Return true to prevent the blur event from being handled. */
196
+ filterBlur?: (e: MouseEvent) => boolean
197
+ /** Return true to prevent the focus event from being handled. */
198
+ filterFocus?: (e: FocusEvent) => boolean
199
+ }
201
200
 
202
201
  interface Props
203
202
  extends
204
203
  /** @vue-ignore */
205
- Partial<Omit<HTMLAttributes,"class" | "onSubmit"> & {
204
+ Partial<Omit<HTMLAttributes, "class" | "onSubmit"> & {
206
205
  /** Tailwind classes. */
207
206
  class?: string
208
207
  }>,
@@ -210,5 +209,4 @@ interface Props
210
209
  WrapperTypes,
211
210
  RealProps
212
211
  {}
213
-
214
212
  </script>
@@ -4,13 +4,11 @@ import type { Meta, StoryObj } from "@storybook/vue3"
4
4
  import LibTable from "./LibTable.vue"
5
5
 
6
6
  // todo
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: Meta<typeof LibTable> = {
12
10
  component: LibTable,
13
- title: "Components/Table",
11
+ title: "Components/Table"
14
12
  }
15
13
 
16
14
  export default meta
@@ -26,81 +24,81 @@ export const Primary: Story = {
26
24
  >
27
25
  </lib-table>
28
26
  </div>
29
- `,
27
+ `
30
28
  }),
31
29
  args: {
32
30
  cols: ["prop1", "prop2", "prop3"],
33
31
  values: [
34
32
  { prop1: "Item1 Prop 1", prop2: "Item1 Prop 2", prop3: "Item1 Prop 3" },
35
33
  { prop1: "Item2 Prop 1", prop2: "Item2 Prop 2", prop3: "Item2 Prop 3" },
36
- { prop1: "Item3 Prop 1", prop2: "Item3 Prop 2", prop3: "Item3 Prop 3" },
34
+ { prop1: "Item3 Prop 1", prop2: "Item3 Prop 2", prop3: "Item3 Prop 3" }
37
35
  ],
38
36
  colConfig: { prop1: { name: "Header 1" }, prop2: { name: "Header 2" } },
39
- itemKey: "prop1",
40
- },
37
+ itemKey: "prop1"
38
+ }
41
39
  }
42
40
 
43
41
  export const NoCellBorders: Story = {
44
42
  ...Primary,
45
43
  args: {
46
44
  ...Primary.args,
47
- cellBorder: false,
48
- },
45
+ cellBorder: false
46
+ }
49
47
  }
50
48
  export const NoBorders: Story = {
51
49
  ...Primary,
52
50
  args: {
53
51
  ...Primary.args,
54
- border: false,
55
- },
52
+ border: false
53
+ }
56
54
  }
57
55
  export const NoCellBordersNoBorders: Story = {
58
56
  ...Primary,
59
57
  args: {
60
58
  ...Primary.args,
61
59
  cellBorder: false,
62
- border: false,
63
- },
60
+ border: false
61
+ }
64
62
  }
65
63
 
66
64
  export const SquareBorders: Story = {
67
65
  ...Primary,
68
66
  args: {
69
67
  ...Primary.args,
70
- rounded: false,
71
- },
68
+ rounded: false
69
+ }
72
70
  }
73
71
  export const NoHeader: Story = {
74
72
  ...Primary,
75
73
  args: {
76
74
  ...Primary.args,
77
- header: false,
78
- },
75
+ header: false
76
+ }
79
77
  }
80
78
  export const NoHeaderNoBorders: Story = {
81
79
  ...Primary,
82
80
  args: {
83
81
  ...Primary.args,
84
82
  header: false,
85
- border: false,
86
- },
83
+ border: false
84
+ }
87
85
  }
88
86
  export const NoHeaderNoCellBorders: Story = {
89
87
  ...Primary,
90
88
  args: {
91
89
  ...Primary.args,
92
90
  header: false,
93
- cellBorder: false,
94
- },
91
+ cellBorder: false
92
+ }
95
93
  }
96
94
  export const FitWidthFalse: Story = {
97
95
  ...Primary,
98
96
  args: {
99
97
  ...Primary.args,
100
98
  resizable: {
101
- fitWidth: false,
102
- },
103
- },
99
+ fitWidth: false
100
+ }
101
+ }
104
102
  }
105
103
 
106
104
  export const ThreeColSomeColsNotResizable: Story = {
@@ -122,18 +120,18 @@ export const ThreeColSomeColsNotResizable: Story = {
122
120
  v-bind="{...args, colConfig:args.colConfig3}"
123
121
  >
124
122
  </lib-table>
125
- `,
123
+ `
126
124
  }),
127
125
  args: {
128
126
  cols: ["prop1", "prop2", "prop3"],
129
127
  itemKey: "prop1",
130
128
  values: [
131
- { prop1: "Prop 1", prop2: "Prop 2", prop3: "Prop 3" },
129
+ { prop1: "Prop 1", prop2: "Prop 2", prop3: "Prop 3" }
132
130
  ],
133
131
  colConfig: { prop1: { name: "No Resize", resizable: false } },
134
132
  colConfig2: { prop2: { name: "No Resize", resizable: false } },
135
- colConfig3: { prop3: { name: "No Resize", resizable: false } },
136
- } as any,
133
+ colConfig3: { prop3: { name: "No Resize", resizable: false } }
134
+ } as any
137
135
  }
138
136
  export const FourColSomeColsNotResizable: Story = {
139
137
  render: args => ({
@@ -154,17 +152,16 @@ export const FourColSomeColsNotResizable: Story = {
154
152
  v-bind="{...args, colConfig:args.colConfig3}"
155
153
  >
156
154
  </lib-table>
157
- `,
155
+ `
158
156
  }),
159
157
  args: {
160
158
  cols: ["prop1", "prop2", "prop3", "prop4"],
161
159
  values: [
162
- { prop1: "Prop 1", prop2: "Prop 2", prop3: "Prop 3", prop4: "Prop 4" },
160
+ { prop1: "Prop 1", prop2: "Prop 2", prop3: "Prop 3", prop4: "Prop 4" }
163
161
  ],
164
162
  itemKey: "prop1",
165
163
  colConfig: { prop1: { name: "No Resize", resizable: false }, prop3: { name: "No Resize", resizable: false } },
166
164
  colConfig2: { prop2: { name: "No Resize", resizable: false }, prop3: { name: "No Resize", resizable: false } },
167
- colConfig3: { prop1: { name: "No Resize", resizable: false }, prop4: { name: "No Resize", resizable: false } },
168
- } as any,
165
+ colConfig3: { prop1: { name: "No Resize", resizable: false }, prop4: { name: "No Resize", resizable: false } }
166
+ } as any
169
167
  }
170
-
@@ -1,6 +1,7 @@
1
1
  <template>
2
2
  <!-- Assumes no scrollbars on children -->
3
- <table :class="twMerge(`table
3
+ <table
4
+ :class="twMerge(`table
4
5
  table-fixed
5
6
  border-separate
6
7
  border-spacing-0
@@ -16,12 +17,12 @@
16
17
  [&.resizable-cols-error]:cursor-not-allowed
17
18
  [&.resizable-cols-error]:user-select-none
18
19
  `,
19
- cellBorder && `
20
+ cellBorder && `
20
21
  [&_td]:border-neutral-500
21
22
  [&_td:not(.last-row)]:border-b
22
23
  [&_td:not(.first-col)]:border-l
23
24
  `,
24
- border && `
25
+ border && `
25
26
  [&_thead_td]:bg-neutral-200
26
27
  [&_td]:border-neutral-500
27
28
  dark:[&_thead_td]:bg-neutral-800
@@ -31,19 +32,26 @@
31
32
  [&_td.last-col]:border-r
32
33
  [&_td.first-col]:border-l
33
34
  `,
34
- rounded &&`
35
+ rounded &&`
35
36
  [&_td.br]:rounded-br-sm
36
37
  [&_td.bl]:rounded-bl-sm
37
38
  [&_td.tr]:rounded-tr-sm
38
39
  [&_td.tl]:rounded-tl-sm
39
- `
40
- , ($attrs as any).class)"
40
+ `,
41
+ ($attrs as any).class)"
41
42
  v-resizable-cols="resizableOptions"
42
43
  >
43
- <thead v-if="header" class="table--header">
44
+ <thead
45
+ v-if="header"
46
+ class="table--header"
47
+ >
44
48
  <tr class="table--row">
45
- <template v-for="col,i of cols" :key="col">
46
- <slot :name="`header-${col.toString()}`"
49
+ <template
50
+ v-for="col, i of cols"
51
+ :key="col"
52
+ >
53
+ <slot
54
+ :name="`header-${col.toString()}`"
47
55
  :class="[
48
56
  extraClasses[`-1-${i}`],
49
57
  'cell table--header-cell',
@@ -54,8 +62,9 @@
54
62
  :style="`width:${widths.length > 0 ? widths[i] : ``}; `"
55
63
  :col-key="col"
56
64
  >
57
- <td :class="[
58
- extraClasses[`-1-${i}`] ,
65
+ <td
66
+ :class="[
67
+ extraClasses[`-1-${i}`],
59
68
  'cell table--header-cell',
60
69
  (colConfig as any)[col]?.resizable === false
61
70
  ? 'no-resize'
@@ -70,9 +79,15 @@
70
79
  </tr>
71
80
  </thead>
72
81
  <tbody class="table--body">
73
- <template v-for="item, i of values" :key="typeof itemKey === 'function' ? itemKey(item) : item[itemKey]">
82
+ <template
83
+ v-for="item, i of values"
84
+ :key="typeof itemKey === 'function' ? itemKey(item) : item[itemKey]"
85
+ >
74
86
  <tr class="table--row">
75
- <template v-for="col, j of cols" :key="(typeof itemKey === 'function' ? itemKey(item) : item[itemKey]) + col.toString()">
87
+ <template
88
+ v-for="col, j of cols"
89
+ :key="(typeof itemKey === 'function' ? itemKey(item) : item[itemKey]) + col.toString()"
90
+ >
76
91
  <slot
77
92
  :name="col"
78
93
  :item="item"
@@ -94,16 +109,15 @@
94
109
  <script setup lang="ts" generic="T">
95
110
  import type { MakeRequired } from "@alanscodelog/utils"
96
111
  import { keys } from "@alanscodelog/utils/keys"
97
- import { computed, type PropType, ref, type TableHTMLAttributes } from "vue"
112
+ import { computed, ref, type TableHTMLAttributes } from "vue"
98
113
 
99
114
  import { vResizableCols } from "../../directives/vResizableCols.js"
100
115
  import type { ResizableOptions, TableColConfig } from "../../types/index.js"
101
116
  import { twMerge } from "../../utils/twMerge.js"
102
117
  import type { TailwindClassProp } from "../shared/props.js"
103
118
 
104
-
105
119
  defineOptions({
106
- name: "lib-table",
120
+ name: "LibTable"
107
121
  })
108
122
 
109
123
  const props = withDefaults(defineProps<Props>(), {
@@ -115,7 +129,7 @@ const props = withDefaults(defineProps<Props>(), {
115
129
  border: true,
116
130
  cellBorder: true,
117
131
  header: true,
118
- colConfig: () => ({}) ,
132
+ colConfig: () => ({})
119
133
  })
120
134
 
121
135
  const widths = ref([])
@@ -123,7 +137,7 @@ const resizableOptions = computed<MakeRequired<Partial<ResizableOptions>, "colCo
123
137
  colCount: props.cols.length,
124
138
  widths,
125
139
  selector: ".cell",
126
- ...props.resizable,
140
+ ...props.resizable
127
141
  }))
128
142
 
129
143
  /* props.values.length instead of `props.values.length - 1` because we're creating an artificial first row for the header */
@@ -136,7 +150,7 @@ const getExtraClasses = (row: number, col: number, isHeader: boolean): string[]
136
150
  "first-row": (isHeader || !props.header) && row === 0,
137
151
  "last-row": row === props.values.length - 1,
138
152
  "first-col": col === 0,
139
- "last-col": col === props.cols.length - 1,
153
+ "last-col": col === props.cols.length - 1
140
154
  }
141
155
  return keys(res).filter(key => res[key])
142
156
  }
@@ -146,16 +160,16 @@ const extraClasses = computed(() => Object.fromEntries([...Array(props.values.le
146
160
  .map(col =>
147
161
  [
148
162
  `${row - 1}-${col}`,
149
- getExtraClasses(row <= 0 ? 0 : row - 1, col, row === 0).join(" "),
163
+ getExtraClasses(row <= 0 ? 0 : row - 1, col, row === 0).join(" ")
150
164
  ]))
151
- .flat(),
165
+ .flat()
152
166
  ))
153
-
154
167
  </script>
168
+
155
169
  <script lang="ts">
156
170
  // generic isn't working here :/
157
171
  type T = any
158
-
172
+
159
173
  type RealProps = {
160
174
  resizable?: Partial<ResizableOptions>
161
175
  values?: T[]
@@ -171,6 +185,6 @@ type RealProps = {
171
185
  interface Props
172
186
  extends
173
187
  /** @vue-ignore */
174
- Partial<Omit<TableHTMLAttributes,"class" | "readonly" | "disabled"> & TailwindClassProp>,
188
+ Partial<Omit<TableHTMLAttributes, "class" | "readonly" | "disabled"> & TailwindClassProp>,
175
189
  RealProps { }
176
190
  </script>
@@ -1,20 +1,18 @@
1
1
  /* eslint-disable @typescript-eslint/naming-convention */
2
2
  import type { Meta, StoryObj } from "@storybook/vue3"
3
3
 
4
-
5
4
  // eslint-disable-next-line @typescript-eslint/no-empty-object-type
6
5
  const meta: Meta<{}> = {
7
6
  title: "Other/Reset",
8
7
  args: {
9
8
 
10
- },
9
+ }
11
10
  }
12
11
 
13
12
  export default meta
14
13
  // eslint-disable-next-line @typescript-eslint/no-empty-object-type
15
14
  type Story = StoryObj<{}>
16
15
 
17
-
18
16
  export const Primary: Story = {
19
17
  render: args => ({
20
18
  setup: () => ({ args }),
@@ -26,7 +24,6 @@ export const Primary: Story = {
26
24
  <h5>h5 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ullamcorper est at dui eleifend, et egestas libero gravida. Phasellus non erat pretium, commodo massa sit amet, accumsan nisl.</h5>
27
25
  <h6>h6 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ullamcorper est at dui eleifend, et egestas libero gravida. Phasellus non erat pretium, commodo massa sit amet, accumsan nisl.</h6>
28
26
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ullamcorper est at dui eleifend, et egestas libero gravida. Phasellus non erat pretium, commodo massa sit amet, accumsan nisl.</p>
29
- `,
30
- }),
27
+ `
28
+ })
31
29
  }
32
-
@@ -1,20 +1,18 @@
1
1
  /* eslint-disable @typescript-eslint/naming-convention */
2
2
  import type { Meta, StoryObj } from "@storybook/vue3"
3
3
 
4
-
5
4
  // eslint-disable-next-line @typescript-eslint/no-empty-object-type
6
5
  const meta: Meta<{}> = {
7
6
  title: "Other/Scrolling",
8
7
  args: {
9
8
 
10
- },
9
+ }
11
10
  }
12
11
 
13
12
  export default meta
14
13
  // eslint-disable-next-line @typescript-eslint/no-empty-object-type
15
14
  type Story = StoryObj<{}>
16
15
 
17
-
18
16
  export const Scrollbars: Story = {
19
17
  render: args => ({
20
18
  setup: () => ({ args }),
@@ -37,8 +35,8 @@ export const Scrollbars: Story = {
37
35
  <div class="h-[1000px] w-[1000px]"/>
38
36
  </div>
39
37
  </div>
40
- `,
41
- }),
38
+ `
39
+ })
42
40
  }
43
41
 
44
42
  export const TextareaResizer: Story = {
@@ -52,7 +50,6 @@ export const TextareaResizer: Story = {
52
50
  min-h-[200px]
53
51
  [resize:both]
54
52
  " />
55
- `,
56
- }),
53
+ `
54
+ })
57
55
  }
58
-
@@ -8,32 +8,32 @@
8
8
  <slot/>
9
9
  </div>
10
10
  </template>
11
+
11
12
  <script setup lang="ts">
12
-
13
+ // remove when copying
14
+ // @ts-nocheck this is a templatek
15
+ /* eslint-disable */
16
+
13
17
  import { type HTMLAttributes, ref } from "vue"
14
18
 
15
19
  import { twMerge } from "../../utils/twMerge.js"
16
- import { type TailwindClassProp } from "../shared/props.js"
17
-
20
+ import type { TailwindClassProp } from "../shared/props.js"
18
21
 
19
22
  defineOptions({
20
- name: "lib-name", /* todo */
21
- inheritAttrs: false,
23
+ name: "LibName", /* todo */
24
+ inheritAttrs: false
22
25
  })
23
26
 
24
-
25
27
  // const props = defineProps<{}>({ })
26
28
 
27
29
  const el = ref<null | HTMLElement>(null)
28
30
 
29
31
  const modelValue = defineModel<string>({ required: true })
30
-
31
-
32
32
  </script>
33
33
 
34
34
  <script lang="ts">
35
35
  export default {
36
- name: "lib-name",
36
+ name: "LibName"
37
37
  }
38
38
 
39
39
  type RealProps = {
@@ -43,7 +43,7 @@ interface Props
43
43
  extends
44
44
  /** @vue-ignore */
45
45
  Partial<Omit<HTMLAttributes, "class">
46
- & TailwindClassProp
47
- & RealProps
46
+ & TailwindClassProp
47
+ & RealProps
48
48
  > { }
49
49
  </script>