@witchcraft/ui 0.0.1 → 0.1.1

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 (224) hide show
  1. package/README.md +18 -28
  2. package/dist/module.d.mts +3 -1
  3. package/dist/module.json +3 -3
  4. package/dist/module.mjs +21 -12
  5. package/dist/runtime/assets/base.css +1 -1
  6. package/dist/runtime/assets/locales/en.json +2 -2
  7. package/dist/runtime/assets/tailwind.css +1 -1
  8. package/dist/runtime/assets/utils.css +1 -0
  9. package/dist/runtime/build/WitchcraftUiResolver.js +1 -1
  10. package/dist/runtime/components/Aria/Aria.vue +5 -9
  11. package/dist/runtime/components/Aria/Aria.vue.d.ts +5 -0
  12. package/dist/runtime/components/Icon/Icon.vue +12 -28
  13. package/dist/runtime/components/Icon/Icon.vue.d.ts +21 -0
  14. package/dist/runtime/components/LibButton/LibButton.vue +93 -117
  15. package/dist/runtime/components/LibButton/LibButton.vue.d.ts +36 -0
  16. package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +53 -76
  17. package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +42 -0
  18. package/dist/runtime/components/LibColorInput/LibColorInput.vue +131 -101
  19. package/dist/runtime/components/LibColorInput/LibColorInput.vue.d.ts +63 -0
  20. package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +326 -296
  21. package/dist/runtime/components/LibColorPicker/LibColorPicker.vue.d.ts +61 -0
  22. package/dist/runtime/components/LibColorPicker/utils/safeConvertToHsva.d.ts +2 -0
  23. package/dist/runtime/components/LibColorPicker/utils/safeConvertToHsva.js +18 -0
  24. package/dist/runtime/components/LibColorPicker/utils/safeConvertToRgba.d.ts +2 -0
  25. package/dist/runtime/components/LibColorPicker/utils/safeConvertToRgba.js +17 -0
  26. package/dist/runtime/components/LibColorPicker/utils/toLowPrecisionRgbaString.d.ts +2 -0
  27. package/dist/runtime/components/LibColorPicker/utils/toLowPrecisionRgbaString.js +8 -0
  28. package/dist/runtime/components/LibColorPicker/utils/truncate.d.ts +1 -0
  29. package/dist/runtime/components/LibColorPicker/utils/truncate.js +5 -0
  30. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +42 -64
  31. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue.d.ts +22 -0
  32. package/dist/runtime/components/LibDatePicker/LibDatePicker.vue +20 -54
  33. package/dist/runtime/components/LibDatePicker/LibDatePicker.vue.d.ts +40 -0
  34. package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue +205 -173
  35. package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue.d.ts +34 -0
  36. package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +215 -164
  37. package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue.d.ts +34 -0
  38. package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue +9 -10
  39. package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue.d.ts +22 -0
  40. package/dist/runtime/components/LibDebug/LibDebug.vue +47 -65
  41. package/dist/runtime/components/LibDebug/LibDebug.vue.d.ts +32 -0
  42. package/dist/runtime/components/LibDevOnly/LibDevOnly.vue +19 -34
  43. package/dist/runtime/components/LibDevOnly/LibDevOnly.vue.d.ts +22 -0
  44. package/dist/runtime/components/LibFileInput/LibFileInput.vue +155 -173
  45. package/dist/runtime/components/LibFileInput/LibFileInput.vue.d.ts +43 -0
  46. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +352 -0
  47. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue.d.ts +165 -0
  48. package/dist/runtime/components/LibLabel/LibLabel.vue +30 -46
  49. package/dist/runtime/components/LibLabel/LibLabel.vue.d.ts +27 -0
  50. package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +50 -66
  51. package/dist/runtime/components/LibMultiValues/LibMultiValues.vue.d.ts +29 -0
  52. package/dist/runtime/components/LibNotifications/LibNotification.vue +48 -56
  53. package/dist/runtime/components/LibNotifications/LibNotification.vue.d.ts +17 -0
  54. package/dist/runtime/components/LibNotifications/LibNotifications.vue +71 -83
  55. package/dist/runtime/components/LibNotifications/LibNotifications.vue.d.ts +13 -0
  56. package/dist/runtime/components/LibPagination/LibPagination.vue +86 -131
  57. package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +104 -0
  58. package/dist/runtime/components/LibPalette/LibPalette.vue +23 -26
  59. package/dist/runtime/components/LibPalette/LibPalette.vue.d.ts +14 -0
  60. package/dist/runtime/components/LibPopup/LibPopup.vue +326 -400
  61. package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +46 -0
  62. package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +73 -93
  63. package/dist/runtime/components/LibProgressBar/LibProgressBar.vue.d.ts +41 -0
  64. package/dist/runtime/components/LibRecorder/LibRecorder.vue +134 -179
  65. package/dist/runtime/components/LibRecorder/LibRecorder.vue.d.ts +77 -0
  66. package/dist/runtime/components/LibRoot/LibRoot.vue +75 -89
  67. package/dist/runtime/components/LibRoot/LibRoot.vue.d.ts +41 -0
  68. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue +51 -82
  69. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue.d.ts +35 -0
  70. package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +147 -164
  71. package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +94 -0
  72. package/dist/runtime/components/LibTable/LibTable.vue +69 -106
  73. package/dist/runtime/components/LibTable/LibTable.vue.d.ts +45 -0
  74. package/dist/runtime/components/Template/NAME.vue +15 -36
  75. package/dist/runtime/components/Template/NAME.vue.d.ts +17 -0
  76. package/dist/runtime/components/TestControls/TestControls.vue +7 -10
  77. package/dist/runtime/components/TestControls/TestControls.vue.d.ts +5 -0
  78. package/dist/runtime/components/index.d.ts +12 -11
  79. package/dist/runtime/components/index.js +12 -11
  80. package/dist/runtime/components/shared/props.d.ts +81 -16
  81. package/dist/runtime/components/shared/storyHelpers/playInput.js +5 -5
  82. package/dist/runtime/components/shared/storyHelpers/playSuggestions.js +15 -11
  83. package/dist/runtime/composables/index.d.ts +5 -0
  84. package/dist/runtime/composables/index.js +5 -0
  85. package/dist/runtime/composables/useDivideAttrs.js +1 -0
  86. package/dist/runtime/composables/useDragWithThreshold.d.ts +71 -0
  87. package/dist/runtime/composables/useDragWithThreshold.js +40 -0
  88. package/dist/runtime/composables/usePreHydrationValue.d.ts +12 -0
  89. package/dist/runtime/composables/usePreHydrationValue.js +15 -0
  90. package/dist/runtime/composables/useSetupI18n.d.ts +2 -0
  91. package/dist/runtime/composables/useSetupI18n.js +5 -1
  92. package/dist/runtime/composables/useSuggestions.d.ts +7 -5
  93. package/dist/runtime/composables/useSuggestions.js +94 -57
  94. package/dist/runtime/directives/vResizableCols.js +92 -84
  95. package/dist/runtime/helpers/NotificationHandler.d.ts +5 -0
  96. package/dist/runtime/helpers/index.d.ts +3 -1
  97. package/dist/runtime/helpers/index.js +3 -1
  98. package/dist/runtime/types/index.d.ts +6 -0
  99. package/dist/runtime/utils/notifyIfError.d.ts +14 -0
  100. package/dist/runtime/utils/notifyIfError.js +29 -0
  101. package/dist/types.d.mts +2 -6
  102. package/package.json +27 -29
  103. package/src/module.ts +31 -12
  104. package/src/runtime/assets/base.css +10 -1
  105. package/src/runtime/assets/locales/en.json +2 -2
  106. package/src/runtime/assets/tailwind.css +1 -1
  107. package/src/runtime/assets/{style.css → utils.css} +86 -4
  108. package/src/runtime/build/WitchcraftUiResolver.ts +1 -1
  109. package/src/runtime/components/Focus.stories.ts +3 -2
  110. package/src/runtime/components/Icon/Icon.vue +10 -6
  111. package/src/runtime/components/LibButton/LibButton.vue +41 -47
  112. package/src/runtime/components/LibCheckbox/LibCheckbox.vue +7 -4
  113. package/src/runtime/components/LibColorInput/LibColorInput.vue +111 -37
  114. package/src/runtime/components/LibColorPicker/LibColorPicker.stories.ts +25 -4
  115. package/src/runtime/components/LibColorPicker/LibColorPicker.vue +242 -131
  116. package/src/runtime/components/LibColorPicker/utils/safeConvertToHsva.ts +24 -0
  117. package/src/runtime/components/LibColorPicker/utils/safeConvertToRgba.ts +23 -0
  118. package/src/runtime/components/LibColorPicker/utils/toLowPrecisionRgbaString.ts +13 -0
  119. package/src/runtime/components/LibColorPicker/utils/truncate.ts +6 -0
  120. package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.ts +1 -1
  121. package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +11 -9
  122. package/src/runtime/components/LibDatePicker/LibDatePicker.vue +4 -17
  123. package/src/runtime/components/LibDatePicker/LibRangeDatePicker.vue +192 -131
  124. package/src/runtime/components/LibDatePicker/LibSingleDatePicker.vue +183 -115
  125. package/src/runtime/components/LibDatePicker/LibTimeZonePicker.vue +3 -3
  126. package/src/runtime/components/LibDebug/LibDebug.vue +15 -5
  127. package/src/runtime/components/LibDevOnly/LibDevOnly.vue +1 -3
  128. package/src/runtime/components/LibFileInput/LibFileInput.vue +54 -29
  129. package/src/runtime/components/{LibInput/LibInput.stories.ts → LibInputDeprecated/LibInputDeprecated.stories.ts} +64 -19
  130. package/{dist/runtime/components/LibInput/LibInput.vue → src/runtime/components/LibInputDeprecated/LibInputDeprecated.vue} +40 -34
  131. package/src/runtime/components/LibLabel/LibLabel.vue +2 -2
  132. package/src/runtime/components/LibMultiValues/LibMultiValues.stories.ts +5 -4
  133. package/src/runtime/components/LibMultiValues/LibMultiValues.vue +11 -13
  134. package/src/runtime/components/LibNotifications/LibNotification.vue +19 -11
  135. package/src/runtime/components/LibNotifications/LibNotifications.stories.ts +2 -2
  136. package/src/runtime/components/LibNotifications/LibNotifications.vue +20 -12
  137. package/src/runtime/components/LibPagination/LibPagination.stories.ts +2 -2
  138. package/src/runtime/components/LibPagination/LibPagination.vue +19 -20
  139. package/src/runtime/components/LibPalette/LibPalette.vue +3 -3
  140. package/src/runtime/components/LibPopup/LibPopup.stories.ts +2 -2
  141. package/src/runtime/components/LibPopup/LibPopup.vue +30 -67
  142. package/src/runtime/components/LibProgressBar/LibProgressBar.vue +3 -2
  143. package/src/runtime/components/LibRecorder/LibRecorder.vue +2 -3
  144. package/src/runtime/components/LibRoot/LibRoot.vue +14 -1
  145. package/src/runtime/components/LibSimpleInput/LibSimpleInput.stories.ts +1 -1
  146. package/src/runtime/components/LibSimpleInput/LibSimpleInput.vue +5 -8
  147. package/src/runtime/components/LibSuggestions/LibSuggestions.vue +42 -26
  148. package/src/runtime/components/LibTable/LibTable.vue +8 -9
  149. package/src/runtime/components/Scrolling.stories.ts +58 -0
  150. package/src/runtime/components/Template/NAME.vue +1 -1
  151. package/src/runtime/components/TestControls/TestControls.vue +1 -1
  152. package/src/runtime/components/index.ts +12 -12
  153. package/src/runtime/components/shared/props.ts +82 -19
  154. package/src/runtime/components/shared/storyHelpers/playInput.ts +6 -5
  155. package/src/runtime/components/shared/storyHelpers/playSuggestions.ts +25 -11
  156. package/src/runtime/composables/index.ts +5 -0
  157. package/src/runtime/composables/useDarkMode.ts +2 -2
  158. package/src/runtime/composables/useDivideAttrs.ts +1 -0
  159. package/src/runtime/composables/useDragWithThreshold.ts +108 -0
  160. package/src/runtime/composables/usePreHydrationValue.ts +30 -0
  161. package/src/runtime/composables/useSetupI18n.ts +8 -2
  162. package/src/runtime/composables/useSuggestions.ts +92 -45
  163. package/src/runtime/directives/vResizableCols.ts +82 -74
  164. package/src/runtime/helpers/NotificationHandler.ts +5 -0
  165. package/src/runtime/helpers/index.ts +3 -1
  166. package/src/runtime/types/index.ts +5 -0
  167. package/src/runtime/utils/notifyIfError.ts +45 -0
  168. package/dist/module.cjs +0 -5
  169. package/dist/module.d.ts +0 -34
  170. package/dist/runtime/assets/style.css +0 -1
  171. package/dist/runtime/components/Focus.stories.d.ts +0 -11
  172. package/dist/runtime/components/Focus.stories.js +0 -53
  173. package/dist/runtime/components/LibButton/LibButton.stories.d.ts +0 -12
  174. package/dist/runtime/components/LibButton/LibButton.stories.js +0 -94
  175. package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.d.ts +0 -14
  176. package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.js +0 -29
  177. package/dist/runtime/components/LibColorInput/LibColorInput.stories.d.ts +0 -7
  178. package/dist/runtime/components/LibColorInput/LibColorInput.stories.js +0 -58
  179. package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.d.ts +0 -7
  180. package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.js +0 -51
  181. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.d.ts +0 -7
  182. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.js +0 -36
  183. package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.d.ts +0 -11
  184. package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.js +0 -98
  185. package/dist/runtime/components/LibDebug/LibDebug.stories.d.ts +0 -9
  186. package/dist/runtime/components/LibDebug/LibDebug.stories.js +0 -46
  187. package/dist/runtime/components/LibFileInput/LibFileInput.stories.d.ts +0 -10
  188. package/dist/runtime/components/LibFileInput/LibFileInput.stories.js +0 -63
  189. package/dist/runtime/components/LibInput/LibInput.stories.d.ts +0 -33
  190. package/dist/runtime/components/LibInput/LibInput.stories.js +0 -339
  191. package/dist/runtime/components/LibLabel/LibLabel.stories.d.ts +0 -6
  192. package/dist/runtime/components/LibLabel/LibLabel.stories.js +0 -25
  193. package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.d.ts +0 -23
  194. package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.js +0 -60
  195. package/dist/runtime/components/LibNotifications/LibNotification.stories.d.ts +0 -15
  196. package/dist/runtime/components/LibNotifications/LibNotification.stories.js +0 -126
  197. package/dist/runtime/components/LibNotifications/LibNotifications.stories.d.ts +0 -6
  198. package/dist/runtime/components/LibNotifications/LibNotifications.stories.js +0 -109
  199. package/dist/runtime/components/LibPagination/LibPagination.stories.d.ts +0 -6
  200. package/dist/runtime/components/LibPagination/LibPagination.stories.js +0 -40
  201. package/dist/runtime/components/LibPalette/LibPalette.stories.d.ts +0 -6
  202. package/dist/runtime/components/LibPalette/LibPalette.stories.js +0 -20
  203. package/dist/runtime/components/LibPopup/LibPopup.stories.d.ts +0 -14
  204. package/dist/runtime/components/LibPopup/LibPopup.stories.js +0 -147
  205. package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.d.ts +0 -10
  206. package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.js +0 -81
  207. package/dist/runtime/components/LibRecorder/LibRecorder.stories.d.ts +0 -19
  208. package/dist/runtime/components/LibRecorder/LibRecorder.stories.js +0 -63
  209. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.d.ts +0 -26
  210. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.js +0 -78
  211. package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.d.ts +0 -27
  212. package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.js +0 -112
  213. package/dist/runtime/components/LibTable/LibTable.stories.d.ts +0 -16
  214. package/dist/runtime/components/LibTable/LibTable.stories.js +0 -156
  215. package/dist/runtime/components/reset.stories.d.ts +0 -5
  216. package/dist/runtime/components/reset.stories.js +0 -19
  217. package/dist/runtime/composables/useScrollNearContainerEdges.stories.d.ts +0 -7
  218. package/dist/runtime/composables/useScrollNearContainerEdges.stories.js +0 -85
  219. package/dist/runtime/helpers/addValue.d.ts +0 -1
  220. package/dist/runtime/helpers/addValue.js +0 -8
  221. package/dist/types.d.ts +0 -7
  222. package/src/runtime/components/LibInput/LibInput.vue +0 -372
  223. package/src/runtime/helpers/addValue.ts +0 -10
  224. /package/src/runtime/components/{reset.stories.ts → Reset.stories.ts} +0 -0
@@ -0,0 +1,352 @@
1
+ <template>
2
+ <div
3
+ :class="twMerge(
4
+ `input--outer-wrapper
5
+ grow
6
+ flex
7
+ flex-wrap
8
+ `,
9
+ disabled && `
10
+ text-neutral-400
11
+ dark:text-neutral-600
12
+ `,
13
+ $.wrapperAttrs?.class
14
+ )"
15
+ tabindex="-1"
16
+ v-bind="{ ...$.wrapperAttrs, class: void 0 }"
17
+ ref="inputWrapperEl"
18
+ >
19
+ <slot name="label" v-bind="{ ...slotProps, label }">
20
+ <lib-label v-if="label || $slots.default"
21
+ :id="id ?? fallbackId"
22
+ :disabled="disabled"
23
+ :readonly="readonly"
24
+ :valid="valid"
25
+ class="input--label"
26
+ >
27
+ <slot v-bind="slotProps">
28
+ {{ label }}
29
+ </slot>
30
+ </lib-label>
31
+ <!-- Allow blurring when clicking the blank part of a label. -->
32
+ <div class="input--label-spacer flex-1"/>
33
+ </slot>
34
+ <!-- These are mostly copies of the classes on LibSimpleInput except made to work with disabled/readonly/etc manually since a div cannot have these states. -->
35
+ <div
36
+ :data-border="border"
37
+ :data-invalid="!valid"
38
+ :data-disabled="disabled"
39
+ :data-read-only="readonly"
40
+ :data-is-open="isOpen"
41
+ v-bind="{ ...$['inner-wrapperAttrs'], class: void 0 }"
42
+ :class="twMerge(
43
+ `input--inner-wrapper
44
+ relative
45
+ flex
46
+ flex-1
47
+ basis-[100%]
48
+ flex-wrap
49
+ rounded-sm
50
+ gap-2
51
+ px-2
52
+ `,
53
+ border && `
54
+ bg-inherit
55
+ border
56
+ border-neutral-500
57
+ outlined-within:border-accent-500
58
+ `,
59
+ isOpen && `rounded-b-none`,
60
+ !valid && `
61
+ border-danger-700
62
+ outlined:!outline-danger-700
63
+ text-danger-800
64
+ dark:text-danger-400
65
+ dark:border-danger-600
66
+ `,
67
+ readonly && `
68
+ bg-neutral-50
69
+ text-neutral-800
70
+ dark:bg-neutral-950
71
+ dark:text-neutral-200
72
+ `,
73
+ disabled && `
74
+ bg-neutral-50
75
+ text-neutral-400
76
+ dark:border-neutral-600
77
+ border-neutral-400
78
+ `,
79
+ $['inner-wrapperAttrs']?.class
80
+ )"
81
+ >
82
+ <slot name="left" v-bind="slotProps"/>
83
+ <slot name="input" v-bind="{ ...inputProps, ...slotProps, suggestionsIndicatorClickHandler }">
84
+ <lib-simple-input
85
+ :class="twMerge(
86
+ `input--input p-0`,
87
+ !$slots.left && `-ml-2 pl-2`,
88
+ !$slots.right && (!$values || $values.length === 0) && !suggestions && `-mr-2 -pr-2`,
89
+ $.attrs?.class
90
+ )"
91
+ v-bind="inputProps"
92
+ />
93
+ </slot>
94
+ <slot name="indicator" v-bind="{ isOpen, suggestionsIndicatorClickHandler }">
95
+ <!-- todo, convert to button for accessibility ? -->
96
+ <div
97
+ v-if="suggestions"
98
+ :data-is-open="isOpen"
99
+ :class="twMerge(`input--indicator flex flex-col justify-center`)"
100
+ @click="suggestionsIndicatorClickHandler"
101
+ >
102
+ <icon :class="isOpen && `rotate-180`"> <i-fa6-solid-chevron-up/> </icon>
103
+ </div>
104
+ </slot>
105
+ <slot
106
+ name="values"
107
+ v-bind="{ ...multivaluesProps, ...slotProps }"
108
+ >
109
+ <template v-if="$values && $values.length > 0">
110
+ <lib-multi-values
111
+ :class="twMerge(
112
+ `
113
+ input--multivalues
114
+ grow-[9000]
115
+ justify-space-between
116
+ py-1
117
+ `,
118
+ !$slots.right && `-mr-1`,
119
+ $.multivaluesAttrs?.class
120
+ )"
121
+ v-bind="multivaluesProps"
122
+ />
123
+ </template>
124
+ </slot>
125
+ <slot name="right" v-bind="slotProps"/>
126
+
127
+ <slot v-if="suggestions" name="suggestions" v-bind="{ ...suggestionProps, ...slotProps }">
128
+ <!-- todo 1px needs to be abstracted to var -->
129
+ <lib-suggestions
130
+ :class="twMerge(
131
+ `
132
+ input--suggestions
133
+ absolute
134
+ -inset-x-px
135
+ z-10
136
+ rounded-b-sm
137
+ border-accent-500
138
+ border
139
+ top-full
140
+ `,
141
+ !border && `
142
+ rounded-sm
143
+ `,
144
+ $.suggestionsAttrs?.class
145
+ )"
146
+ ref="suggestionsComponent"
147
+ v-bind="suggestionProps"
148
+ >
149
+ <template #item="itemSlotProps">
150
+ <slot name="suggestion-item" v-bind="itemSlotProps"/>
151
+ </template>
152
+ </lib-suggestions>
153
+ </slot>
154
+ </div>
155
+ </div>
156
+ </template>
157
+
158
+ <script setup>
159
+ import { isBlank } from "@alanscodelog/utils/isBlank.js";
160
+ import { isObject } from "@alanscodelog/utils/isObject.js";
161
+ import { pushIfNotIn } from "@alanscodelog/utils/pushIfNotIn.js";
162
+ import { computed, nextTick, onBeforeMount, ref, toRef, useSlots, watch } from "vue";
163
+ import { useDivideAttrs } from "../../composables/useDivideAttrs.js";
164
+ import { useSuggestionsInputAria } from "../../composables/useSuggestions.js";
165
+ import { twMerge } from "../../utils/twMerge.js";
166
+ import Icon from "../Icon/Icon.vue";
167
+ import LibLabel from "../LibLabel/LibLabel.vue";
168
+ import LibMultiValues from "../LibMultiValues/LibMultiValues.vue";
169
+ import LibSimpleInput from "../LibSimpleInput/LibSimpleInput.vue";
170
+ import LibSuggestions from "../LibSuggestions/LibSuggestions.vue";
171
+ import { baseInteractivePropsDefaults, getFallbackId } from "../shared/props.js";
172
+ defineOptions({
173
+ name: "lib-simple-input-deprecated",
174
+ inheritAttrs: false
175
+ });
176
+ const $slots = useSlots();
177
+ const emit = defineEmits(["input", "submit", "keydown", "blur", "focus", "indicatorClick"]);
178
+ const fallbackId = getFallbackId();
179
+ const props = defineProps(/* @__PURE__ */ _mergeDefaults({
180
+ suggestions: { type: Array, required: false },
181
+ suggestionLabel: { type: Function, required: false },
182
+ restrictToSuggestions: { type: Boolean, required: false },
183
+ updateOnlyOnSubmit: { type: Boolean, required: false },
184
+ suggestionsFilter: { type: Function, required: false },
185
+ allowOpenEmpty: { type: Boolean, required: false },
186
+ canOpen: { type: Boolean, required: false },
187
+ canClose: { type: Boolean, required: false },
188
+ isValid: { type: Boolean, required: false },
189
+ suggestionSelector: { type: Function, required: false },
190
+ showSelectedValues: { type: Boolean, required: false },
191
+ id: { type: String, required: false },
192
+ label: { type: String, required: false },
193
+ disabled: { type: Boolean, required: false },
194
+ readonly: { type: Boolean, required: false },
195
+ border: { type: Boolean, required: false },
196
+ unstyle: { type: Boolean, required: false },
197
+ valid: { type: Boolean, required: false }
198
+ }, {
199
+ valid: true,
200
+ suggestions: void 0,
201
+ updateOnlyOnSubmit: false,
202
+ ...baseInteractivePropsDefaults
203
+ }));
204
+ const $ = useDivideAttrs(["wrapper", "inner-wrapper", "suggestions", "multivalues"]);
205
+ const $values = defineModel("values", { type: null, ...{ default: void 0 } });
206
+ const $modelValue = defineModel({ type: String, ...{ required: true } });
207
+ const fullId = computed(() => props.id ?? fallbackId);
208
+ const $inputValue = defineModel("inputValue", { type: String, ...{ default: "" } });
209
+ $inputValue.value = $modelValue.value ?? "";
210
+ const canEdit = computed(() => !props.disabled && !props.readonly);
211
+ const suggestionsComponent = ref(null);
212
+ const activeSuggestion = ref(0);
213
+ watch($modelValue, () => {
214
+ $inputValue.value = $modelValue.value;
215
+ });
216
+ const inputWrapperEl = ref(null);
217
+ const isOpen = ref(false);
218
+ const suggestionsIndicatorClickHandler = (e) => {
219
+ nextTick(() => {
220
+ if (props.suggestions) {
221
+ suggestionsComponent.value?.suggestions.toggle();
222
+ }
223
+ });
224
+ emit("indicatorClick", e);
225
+ };
226
+ const handleKeydown = (e) => {
227
+ if (props.suggestions) {
228
+ if (e.key === "Enter" && activeSuggestion.value === -1 && $values.value) {
229
+ pushIfNotIn($values.value, [$inputValue.value]);
230
+ $inputValue.value = "";
231
+ $modelValue.value = "";
232
+ } else {
233
+ suggestionsComponent.value?.inputKeydownHandler?.(e);
234
+ if ($values.value) {
235
+ $modelValue.value = "";
236
+ }
237
+ }
238
+ }
239
+ emit("keydown", e);
240
+ };
241
+ const handleBlur = (e) => {
242
+ if (props.suggestions) {
243
+ suggestionsComponent.value?.inputBlurHandler?.(e);
244
+ }
245
+ emit("blur", e);
246
+ };
247
+ const handleFocus = (e) => {
248
+ if (props.suggestions) {
249
+ suggestionsComponent.value?.inputFocusHandler?.(e);
250
+ }
251
+ emit("focus", e);
252
+ };
253
+ function addValue(val) {
254
+ if ($values.value === void 0) return;
255
+ if (isBlank(val)) return;
256
+ pushIfNotIn($values.value, [val]);
257
+ $inputValue.value = "";
258
+ $modelValue.value = "";
259
+ }
260
+ const suggestions = toRef(props, "suggestions");
261
+ const inputAriaProps = useSuggestionsInputAria(
262
+ fullId,
263
+ isOpen,
264
+ activeSuggestion,
265
+ suggestions
266
+ );
267
+ const inputProps = computed(() => ({
268
+ id: fullId.value,
269
+ border: false,
270
+ disabled: props.disabled,
271
+ readonly: props.readonly,
272
+ isValid: props.valid,
273
+ onKeydown: handleKeydown,
274
+ onBlur: handleBlur,
275
+ onFocus: handleFocus,
276
+ modelValue: $inputValue.value,
277
+ "onUpdate:modelValue": (e) => {
278
+ $inputValue.value = e;
279
+ if (!props.suggestions && !props.updateOnlyOnSubmit && !props.restrictToSuggestions) {
280
+ $modelValue.value = e;
281
+ }
282
+ },
283
+ onSubmit: (e) => {
284
+ if (!props.suggestions) {
285
+ $modelValue.value = $values.value ? "" : e;
286
+ emit("submit", e);
287
+ if ($values.value) {
288
+ addValue(e);
289
+ }
290
+ }
291
+ },
292
+ ...inputAriaProps.value,
293
+ canEdit: canEdit.value,
294
+ ...$.value.attrs,
295
+ class: void 0
296
+ }));
297
+ function slotSubmit(val, _wasRemoved) {
298
+ emit("submit", val);
299
+ }
300
+ const slotProps = computed(() => ({
301
+ id: fullId.value,
302
+ isOpen: isOpen.value,
303
+ valid: props.valid,
304
+ disabled: props.disabled,
305
+ readonly: props.readonly,
306
+ emitSubmit: slotSubmit
307
+ }));
308
+ const suggestionProps = computed(() => ({
309
+ id: fullId.value,
310
+ suggestions: props.suggestions,
311
+ allowOpenEmpty: props.allowOpenEmpty,
312
+ restrictToSuggestions: props.restrictToSuggestions,
313
+ suggestionLabel: props.suggestionLabel,
314
+ suggestionsFilter: props.suggestionsFilter,
315
+ modelValue: $values.value ?? $modelValue.value.toString(),
316
+ inputValue: $inputValue.value,
317
+ isValid: props.isValid,
318
+ "onUpdate:inputValue": (e) => $inputValue.value = e,
319
+ onSubmit: (e, suggestion, wasRemoved) => {
320
+ $modelValue.value = wasRemoved ? "" : e;
321
+ emit("submit", e, suggestion);
322
+ },
323
+ "onUpdate:modelValue": (e) => {
324
+ $values.value &&= e;
325
+ },
326
+ "onUpdate:isOpen": (e) => {
327
+ isOpen.value = e;
328
+ },
329
+ "onUpdate:activeSuggestion": (e) => activeSuggestion.value = e,
330
+ ...$.value.suggestionsAttrs,
331
+ class: void 0
332
+ }));
333
+ const multivaluesProps = computed(() => ({
334
+ hasSlotRight: !$slots.right,
335
+ label: props.label,
336
+ border: props.border,
337
+ disabled: props.disabled,
338
+ readonly: props.readonly,
339
+ modelValue: $values.value,
340
+ "onUpdate:modelValue": (e) => $values.value = e,
341
+ ...$.value.multivaluesAttrs,
342
+ class: void 0
343
+ }));
344
+ defineExpose({
345
+ suggestionsComponent,
346
+ el: inputWrapperEl
347
+ });
348
+ </script>
349
+
350
+ <script>
351
+
352
+ </script>
@@ -0,0 +1,165 @@
1
+ import { type HTMLAttributes, type InputHTMLAttributes } from "vue";
2
+ import { type BaseInteractiveProps, type LabelProps, type LinkableByIdProps, type SuggestionsProps, type TailwindClassProp, type WrapperProps } from "../shared/props.js.js";
3
+ type WrapperTypes = WrapperProps<"suggestions", HTMLAttributes> & WrapperProps<"wrapper", HTMLAttributes> & WrapperProps<"inner-wrapper", HTMLAttributes>;
4
+ type RealProps = SuggestionsProps & LinkableByIdProps & LabelProps & BaseInteractiveProps & {
5
+ suggestions?: SuggestionsProps["suggestions"];
6
+ valid?: boolean;
7
+ };
8
+ interface Props extends
9
+ /** @vue-ignore */
10
+ Partial<Omit<InputHTMLAttributes, "class" | "readonly" | "disabled" | "onSubmit"> & TailwindClassProp>,
11
+ /** @vue-ignore */
12
+ Partial<WrapperTypes>, RealProps {
13
+ }
14
+ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<Props & {
15
+ values?: string[] | undefined;
16
+ modelValue: string;
17
+ inputValue?: string;
18
+ }, {
19
+ suggestionsComponent: import("vue").Ref<{
20
+ suggestions: {
21
+ list: any[] | undefined;
22
+ filtered: any[] | undefined;
23
+ active: number;
24
+ available: boolean;
25
+ moreThanOneAvailable: boolean;
26
+ hasExactlyMatching: string | object | undefined;
27
+ hasValidSuggestion: boolean;
28
+ openable: boolean | undefined;
29
+ getLabel: (item: any) => string;
30
+ $open: boolean;
31
+ open: () => void;
32
+ close: () => void;
33
+ enterSelected: (doClose?: boolean) => void;
34
+ enterIndex: (num: number, doClose?: boolean) => void;
35
+ toggle: () => void;
36
+ cancel: () => void;
37
+ select: (num: number) => void;
38
+ prev: () => void;
39
+ next: () => void;
40
+ first: () => void;
41
+ last: () => void;
42
+ };
43
+ el: HTMLElement | null;
44
+ inputKeydownHandler: (e: KeyboardEvent) => void;
45
+ inputBlurHandler: (e: MouseEvent) => void;
46
+ inputFocusHandler: (e: FocusEvent) => void;
47
+ } | null, import("vue").ShallowUnwrapRef<{
48
+ suggestions: {
49
+ list: any[] | undefined;
50
+ filtered: any[] | undefined;
51
+ active: number;
52
+ available: boolean;
53
+ moreThanOneAvailable: boolean;
54
+ hasExactlyMatching: string | object | undefined;
55
+ hasValidSuggestion: boolean;
56
+ openable: boolean | undefined;
57
+ getLabel: (item: any) => string;
58
+ $open: boolean;
59
+ open: () => void;
60
+ close: () => void;
61
+ enterSelected: (doClose?: boolean) => void;
62
+ enterIndex: (num: number, doClose?: boolean) => void;
63
+ toggle: () => void;
64
+ cancel: () => void;
65
+ select: (num: number) => void;
66
+ prev: () => void;
67
+ next: () => void;
68
+ first: () => void;
69
+ last: () => void;
70
+ };
71
+ el: import("vue").Ref<HTMLElement | null, HTMLElement | null>;
72
+ inputKeydownHandler: (e: KeyboardEvent) => void;
73
+ inputBlurHandler: (e: MouseEvent) => void;
74
+ inputFocusHandler: (e: FocusEvent) => void;
75
+ }> | {
76
+ suggestions: {
77
+ list: any[] | undefined;
78
+ filtered: any[] | undefined;
79
+ active: number;
80
+ available: boolean;
81
+ moreThanOneAvailable: boolean;
82
+ hasExactlyMatching: string | object | undefined;
83
+ hasValidSuggestion: boolean;
84
+ openable: boolean | undefined;
85
+ getLabel: (item: any) => string;
86
+ $open: boolean;
87
+ open: () => void;
88
+ close: () => void;
89
+ enterSelected: (doClose?: boolean) => void;
90
+ enterIndex: (num: number, doClose?: boolean) => void;
91
+ toggle: () => void;
92
+ cancel: () => void;
93
+ select: (num: number) => void;
94
+ prev: () => void;
95
+ next: () => void;
96
+ first: () => void;
97
+ last: () => void;
98
+ };
99
+ el: HTMLElement | null;
100
+ inputKeydownHandler: (e: KeyboardEvent) => void;
101
+ inputBlurHandler: (e: MouseEvent) => void;
102
+ inputFocusHandler: (e: FocusEvent) => void;
103
+ } | null>;
104
+ el: import("vue").Ref<HTMLElement | null, HTMLElement | null>;
105
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
106
+ "update:modelValue": (value: string) => any;
107
+ "update:inputValue": (value: string) => any;
108
+ "update:values": (value: string[] | undefined) => any;
109
+ } & {
110
+ blur: (val: FocusEvent) => any;
111
+ input: (val: InputEvent) => any;
112
+ submit: (val: string, suggestion?: any) => any;
113
+ keydown: (val: KeyboardEvent) => any;
114
+ focus: (val: FocusEvent) => any;
115
+ indicatorClick: (val: MouseEvent) => any;
116
+ }, string, import("vue").PublicProps, Readonly<Props & {
117
+ values?: string[] | undefined;
118
+ modelValue: string;
119
+ inputValue?: string;
120
+ }> & Readonly<{
121
+ onBlur?: ((val: FocusEvent) => any) | undefined;
122
+ onInput?: ((val: InputEvent) => any) | undefined;
123
+ onSubmit?: ((val: string, suggestion?: any) => any) | undefined;
124
+ "onUpdate:modelValue"?: ((value: string) => any) | undefined;
125
+ "onUpdate:inputValue"?: ((value: string) => any) | undefined;
126
+ "onUpdate:values"?: ((value: string[] | undefined) => any) | undefined;
127
+ onKeydown?: ((val: KeyboardEvent) => any) | undefined;
128
+ onFocus?: ((val: FocusEvent) => any) | undefined;
129
+ onIndicatorClick?: ((val: MouseEvent) => any) | undefined;
130
+ }>, {
131
+ disabled: boolean;
132
+ readonly: boolean;
133
+ border: boolean;
134
+ unstyle: boolean;
135
+ valid: boolean;
136
+ suggestions: any[];
137
+ updateOnlyOnSubmit: boolean;
138
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
139
+ label?: (props: any) => any;
140
+ } & {
141
+ default?: (props: any) => any;
142
+ } & {
143
+ left?: (props: any) => any;
144
+ } & {
145
+ input?: (props: any) => any;
146
+ } & {
147
+ indicator?: (props: {
148
+ isOpen: any;
149
+ suggestionsIndicatorClickHandler: any;
150
+ }) => any;
151
+ } & {
152
+ values?: (props: any) => any;
153
+ } & {
154
+ right?: (props: any) => any;
155
+ } & {
156
+ suggestions?: (props: any) => any;
157
+ } & {
158
+ 'suggestion-item'?: (props: any) => any;
159
+ }>;
160
+ export default _default;
161
+ type __VLS_WithSlots<T, S> = T & {
162
+ new (): {
163
+ $slots: S;
164
+ };
165
+ };
@@ -2,65 +2,49 @@
2
2
  <!-- we use data-disabled because labels have no disabled property technically -->
3
3
  <label
4
4
  :id="`label-${id ?? fallbackId}`"
5
- :class="!($attrs as any).unstyle && twMerge(`
5
+ :class="!$attrs.unstyle && twMerge(
6
+ `
6
7
  pr-0
7
8
  text-sm
8
9
  `,
9
- !valid && `text-danger-700`,
10
- ($attrs as any)?.class
11
- )"
10
+ !valid && `text-danger-700`,
11
+ $attrs?.class
12
+ )"
12
13
  :data-disabled="disabled"
13
14
  :data-invalid="!valid"
14
15
  :for="id"
15
- v-bind="{...$attrs, class:undefined}"
16
+ v-bind="{ ...$attrs, class: void 0 }"
16
17
  >
17
18
  <slot/>
18
19
  </label>
19
20
  </template>
20
21
 
21
- <script setup lang="ts">
22
- import type { MakeRequired } from "@alanscodelog/utils/types"
23
- import { type LabelHTMLAttributes,toRef,useAttrs } from "vue"
24
-
25
- import { twMerge } from "../../utils/twMerge.js"
26
- import { type BaseInteractiveProps, baseInteractivePropsDefaults, getFallbackId, type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js"
27
-
28
-
22
+ <script setup>
23
+ import { toRef, useAttrs } from "vue";
24
+ import { twMerge } from "../../utils/twMerge.js";
25
+ import { baseInteractivePropsDefaults, getFallbackId } from "../shared/props.js";
29
26
  defineOptions({
30
- name: "lib-label",
31
- })
32
-
33
- const fallbackId = getFallbackId()
34
-
35
-
36
- withDefaults(defineProps<Props>(), {
37
- id: "",
38
- unstyled: undefined,
39
- valid: true,
40
- ...baseInteractivePropsDefaults,
41
- })
42
-
43
- const $attrs = useAttrs()
44
- </script>
45
-
46
- <script lang="ts">
47
- type RealProps =
48
- & LinkableByIdProps
49
- & LabelProps
50
- & BaseInteractiveProps
51
- & {
52
- unstyled?: boolean
53
- valid?: boolean
54
- }
55
-
56
- interface Props
57
- extends
58
- /** @vue-ignore */
59
- Partial<Omit<LabelHTMLAttributes,"class"> & TailwindClassProp>,
60
- RealProps
61
- {}
27
+ name: "lib-label"
28
+ });
29
+ const fallbackId = getFallbackId();
30
+ defineProps(/* @__PURE__ */ _mergeDefaults({
31
+ id: { type: String, required: false },
32
+ label: { type: String, required: false },
33
+ disabled: { type: Boolean, required: false },
34
+ readonly: { type: Boolean, required: false },
35
+ border: { type: Boolean, required: false },
36
+ unstyle: { type: Boolean, required: false },
37
+ unstyled: { type: Boolean, required: false },
38
+ valid: { type: Boolean, required: false }
39
+ }, {
40
+ id: "",
41
+ unstyled: void 0,
42
+ valid: true,
43
+ ...baseInteractivePropsDefaults
44
+ }));
45
+ const $attrs = useAttrs();
62
46
  </script>
63
47
 
64
- <script lang="ts">
48
+ <script>
65
49
 
66
50
  </script>
@@ -0,0 +1,27 @@
1
+ import { type LabelHTMLAttributes } from "vue";
2
+ import { type BaseInteractiveProps, type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js.js";
3
+ type RealProps = LinkableByIdProps & LabelProps & BaseInteractiveProps & {
4
+ unstyled?: boolean;
5
+ valid?: boolean;
6
+ };
7
+ interface Props extends
8
+ /** @vue-ignore */
9
+ Partial<Omit<LabelHTMLAttributes, "class"> & TailwindClassProp>, RealProps {
10
+ }
11
+ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<Props, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
12
+ id: string;
13
+ disabled: boolean;
14
+ readonly: boolean;
15
+ border: boolean;
16
+ unstyle: boolean;
17
+ unstyled: boolean;
18
+ valid: boolean;
19
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
20
+ default?: (props: {}) => any;
21
+ }>;
22
+ export default _default;
23
+ type __VLS_WithSlots<T, S> = T & {
24
+ new (): {
25
+ $slots: S;
26
+ };
27
+ };