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