@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
@@ -0,0 +1,77 @@
1
+ import { type HTMLAttributes } from "vue";
2
+ import { type BaseInteractiveProps, type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js.js";
3
+ type RealProps = LinkableByIdProps & BaseInteractiveProps & LabelProps & {
4
+ border?: boolean;
5
+ /** A value to display while recording, if none given the i18n `recorder.recording` key is used. */
6
+ recordingValue?: string;
7
+ /** A title to display on the input div while recording. Is also used as the aria-description. */
8
+ recordingTitle?: string;
9
+ /**
10
+ * The recorder object is a series of event listeners to attach to the input div while recording is started. If you need to bind directly to the element, see the `binders` prop.
11
+ *
12
+ * The listeners are then unbound when recording is set to false again.
13
+ *
14
+ * Note that the component does not handle the setting of `recording` (unless the component is disabled), `modelValue`, or `recordingValue` at all and has no mechanism for cancelling a recording. It is left to the recorder listeners and any `recorder:*` handlers to determine what to do.
15
+ */
16
+ recorder?: undefined | Record<string, any>;
17
+ /** This provides a way to manually attach/remove event listeners to/from the element. It is an alternative to the `recorder` prop, see it for more details. Both cannot be specified at the same time.*/
18
+ binders?: undefined | {
19
+ bind: (el: HTMLElement) => void;
20
+ unbind: (el: HTMLElement) => void;
21
+ };
22
+ /** The id of the element. If not provided, the id will be generated automatically. */
23
+ id?: string;
24
+ };
25
+ interface Props extends
26
+ /** @vue-ignore */
27
+ Partial<Omit<HTMLAttributes, "class"> & TailwindClassProp>, RealProps {
28
+ }
29
+ declare const _default: import("vue").DefineComponent<Props & {
30
+ /**
31
+ * Puts the element into recording mode if true. See {@link props.recorder}.
32
+ */
33
+ recording?: boolean;
34
+ /** The final value of the recorder. For intermediate values while recording, pass a recorder and set an appropriate recording value. */
35
+ modelValue: string;
36
+ }, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
37
+ "update:modelValue": (value: string) => any;
38
+ "update:recording": (value: boolean) => any;
39
+ } & {
40
+ "recorder:blur": ($event: FocusEvent) => any;
41
+ "recorder:click": (args_0: {
42
+ event: MouseEvent | KeyboardEvent;
43
+ indicator: HTMLElement;
44
+ input: HTMLInputElement;
45
+ }) => any;
46
+ "focus:parent": () => any;
47
+ }, string, import("vue").PublicProps, Readonly<Props & {
48
+ /**
49
+ * Puts the element into recording mode if true. See {@link props.recorder}.
50
+ */
51
+ recording?: boolean;
52
+ /** The final value of the recorder. For intermediate values while recording, pass a recorder and set an appropriate recording value. */
53
+ modelValue: string;
54
+ }> & Readonly<{
55
+ "onUpdate:modelValue"?: ((value: string) => any) | undefined;
56
+ "onUpdate:recording"?: ((value: boolean) => any) | undefined;
57
+ "onRecorder:blur"?: (($event: FocusEvent) => any) | undefined;
58
+ "onRecorder:click"?: ((args_0: {
59
+ event: MouseEvent | KeyboardEvent;
60
+ indicator: HTMLElement;
61
+ input: HTMLInputElement;
62
+ }) => any) | undefined;
63
+ "onFocus:parent"?: (() => any) | undefined;
64
+ }>, {
65
+ id: string;
66
+ disabled: boolean;
67
+ readonly: boolean;
68
+ border: boolean;
69
+ unstyle: boolean;
70
+ recordingTitle: string;
71
+ recorder: Record<string, any>;
72
+ binders: {
73
+ bind: (el: HTMLElement) => void;
74
+ unbind: (el: HTMLElement) => void;
75
+ };
76
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
77
+ export default _default;
@@ -2,138 +2,112 @@
2
2
  <div :id="id"
3
3
  tabindex="-1"
4
4
  :class="twMerge(
5
- (showOutline ? 'group outlined outlined-visible' : '[&_*]:outline-hidden'),
6
- darkMode && ' dark',
7
- ($attrs['wrapperAttrs'] as any)?.class
8
- )"
9
- v-bind="{ ...($attrs['wrapperAttrs']), attrs:undefined, class: undefined }"
5
+ showOutline ? 'group outlined outlined-visible' : '[&_*]:outline-hidden',
6
+ darkMode && ' dark',
7
+ $attrs['wrapperAttrs']?.class
8
+ )"
9
+ v-bind="{ ...$attrs['wrapperAttrs'], attrs: void 0, class: void 0 }"
10
10
  :ref="handleRef"
11
11
  >
12
12
  <!-- id root is useful for teleports, so they are at the topmost level where they can still be styled -->
13
13
  <!-- See TestControls for why the margins here -->
14
14
  <div
15
15
  id="root"
16
- v-bind="{ ...$attrs.attrs, class: undefined, wrapperAttrs: undefined }"
17
- :class="twMerge( `
16
+ v-bind="{ ...$attrs.attrs, class: void 0, wrapperAttrs: void 0 }"
17
+ :class="twMerge(
18
+ `
18
19
  dark:bg-fg
19
20
  dark:text-bg
20
21
  bg-bg
21
22
  text-fg
22
23
  `,
23
- testWrapperMode && `
24
+ testWrapperMode && `
24
25
  px-10
25
26
  pb-10
26
27
  `,
27
- !testWrapperMode && `
28
+ !testWrapperMode && `
28
29
  min-h-dvh
29
30
  flex
30
31
  flex-col
31
32
  `,
32
- ($attrs as any).attrs?.class)"
33
+ $attrs.attrs?.class
34
+ )"
33
35
  >
34
36
  <TestControls v-if="testWrapperMode" :show-outline="showOutline"/>
35
- <Notifications v-if="useNotifications && isClientSide"/>
37
+ <!-- @vue-expect-error data-allow-mismatch is for vue/nuxt to allow the hydration mismatch-->
38
+ <Notifications v-if="useNotifications && isClientSide" data-allow-mismatch/>
36
39
  <slot/>
37
40
  </div>
38
41
  </div>
39
42
  </template>
40
43
 
41
- <script setup lang="ts">
42
- import { unreachable } from "@alanscodelog/utils/unreachable.js"
43
- import { type Theme } from "metamorphosis"
44
- import { type ComponentPublicInstance, computed, onBeforeUnmount, onMounted, ref, toRaw } from "vue"
45
-
46
- import { useAccesibilityOutline } from "../../composables/useAccesibilityOutline.js"
47
- import { useDivideAttrs } from "../../composables/useDivideAttrs.js"
48
- import { useNotificationHandler } from "../../composables/useNotificationHandler.js"
49
- import { useSetupDarkMode } from "../../composables/useSetupDarkMode.js"
50
- import { useSetupI18n } from "../../composables/useSetupI18n.js"
51
- import { useSetupLocale } from "../../composables/useSetupLocale.js"
52
- import { useShowDevOnlyKey } from "../../composables/useShowDevOnlyKey.js"
53
- import { NotificationHandler } from "../../helpers/NotificationHandler.js"
54
- import { theme as defaultTheme } from "../../theme.js"
55
- import { twMerge } from "../../utils/twMerge.js"
56
- import Notifications from "../LibNotifications/LibNotifications.vue"
57
- import TestControls from "../TestControls/TestControls.vue"
58
-
59
- const $attrs = useDivideAttrs(["wrapper"])
60
-
61
- defineOptions({ name: "root", inheritAttrs: false, suspensible: false })
62
- const props = withDefaults(defineProps<{
63
- theme?: Theme
64
- outline?: boolean
65
- forceOutline?: boolean
66
- testWrapperMode?: boolean
67
- id?: string
68
- /** You can set a ref to the root element by passing :getRef="_ => el = _" */
69
- getRef?: (el: HTMLElement | null) => void
70
- /** True by default, should be passed import.meta.client if using nuxt, or false when running server side. */
71
- isClientSide?: boolean
72
- useBuiltinTranslations?: boolean
73
- useNotifications?: boolean
74
- notificationHandler?: NotificationHandler
75
- }>(), {
76
- theme: undefined,
77
- testWrapperMode: false,
78
- outline: true,
79
- forceOutline: false,
80
- id: "app",
81
- getRef: undefined,
82
- isClientSide: true,
83
- useBuiltinTranslations: true,
84
- useNotifications: true,
85
- notificationHandler: undefined
86
- })
87
-
88
- const el = ref<HTMLElement | null>(null)
89
-
90
- function handleRef(_: Element | ComponentPublicInstance | null): void {
91
- if (_ !== null && !(_ instanceof HTMLElement)) unreachable()
92
- el.value = _
93
- props.getRef?.(_)
44
+ <script setup>
45
+ import { unreachable } from "@alanscodelog/utils/unreachable";
46
+ import {} from "metamorphosis";
47
+ import { computed, onBeforeUnmount, onMounted, ref, toRaw } from "vue";
48
+ import { useAccesibilityOutline } from "../../composables/useAccesibilityOutline.js";
49
+ import { useDivideAttrs } from "../../composables/useDivideAttrs.js";
50
+ import { useNotificationHandler } from "../../composables/useNotificationHandler.js";
51
+ import { useSetupDarkMode } from "../../composables/useSetupDarkMode.js";
52
+ import { useSetupI18n } from "../../composables/useSetupI18n.js";
53
+ import { useSetupLocale } from "../../composables/useSetupLocale.js";
54
+ import { useShowDevOnlyKey } from "../../composables/useShowDevOnlyKey.js";
55
+ import { NotificationHandler } from "../../helpers/NotificationHandler.js";
56
+ import { theme as defaultTheme } from "../../theme.js";
57
+ import { twMerge } from "../../utils/twMerge.js";
58
+ import Notifications from "../LibNotifications/LibNotifications.vue";
59
+ import TestControls from "../TestControls/TestControls.vue";
60
+ const $attrs = useDivideAttrs(["wrapper"]);
61
+ defineOptions({ name: "root", inheritAttrs: false, suspensible: false });
62
+ const props = defineProps({
63
+ theme: { type: Object, required: false, default: void 0 },
64
+ outline: { type: Boolean, required: false, default: true },
65
+ forceOutline: { type: Boolean, required: false, default: false },
66
+ testWrapperMode: { type: Boolean, required: false, default: false },
67
+ id: { type: String, required: false, default: "app" },
68
+ getRef: { type: Function, required: false, default: void 0 },
69
+ isClientSide: { type: Boolean, required: false, default: true },
70
+ useBuiltinTranslations: { type: Boolean, required: false, default: true },
71
+ useNotifications: { type: Boolean, required: false, default: true },
72
+ notificationHandler: { type: Object, required: false, default: void 0 }
73
+ });
74
+ const el = ref(null);
75
+ function handleRef(_) {
76
+ if (_ !== null && !(_ instanceof HTMLElement)) unreachable();
77
+ el.value = _;
78
+ props.getRef?.(_);
94
79
  }
95
-
96
80
  if (props.useNotifications) {
97
- const handler = props.notificationHandler ?? new NotificationHandler()
98
- useNotificationHandler(handler, props.isClientSide)
99
- }
100
-
101
- const autoOutline = useAccesibilityOutline(el).outline
102
-
103
- const showOutline = computed(() => (props.outline && autoOutline.value) || props.forceOutline)
104
-
105
- const theme = computed(() => props.theme ?? defaultTheme)
106
- const themeCb = (): void => {
107
- toRaw(theme.value).attach(el.value!)
81
+ const handler = props.notificationHandler ?? new NotificationHandler();
82
+ useNotificationHandler(handler, props.isClientSide);
108
83
  }
84
+ const autoOutline = useAccesibilityOutline(el).outline;
85
+ const showOutline = computed(() => props.outline && autoOutline.value || props.forceOutline);
86
+ const theme = computed(() => props.theme ?? defaultTheme);
87
+ const themeCb = () => {
88
+ toRaw(theme.value).attach(el.value);
89
+ };
109
90
  if (props.isClientSide) {
110
- onMounted(() => {
111
- toRaw(theme.value).on("change", themeCb)
112
- themeCb()
113
- })
114
- onBeforeUnmount(() => {
115
- toRaw(theme.value).off("change", themeCb)
116
- })
91
+ onMounted(() => {
92
+ toRaw(theme.value).on("change", themeCb);
93
+ themeCb();
94
+ });
95
+ onBeforeUnmount(() => {
96
+ toRaw(theme.value).off("change", themeCb);
97
+ });
117
98
  }
118
-
119
- const darkModeSetup = useSetupDarkMode({ isClientSide: props.isClientSide })
120
-
121
- const darkMode = darkModeSetup.darkMode
122
-
123
- useShowDevOnlyKey()
124
-
99
+ const darkModeSetup = useSetupDarkMode({ isClientSide: props.isClientSide });
100
+ const darkMode = darkModeSetup.darkMode;
101
+ useShowDevOnlyKey();
125
102
  defineExpose({
126
- darkMode: darkModeSetup,
127
- })
128
-
103
+ darkMode: darkModeSetup
104
+ });
129
105
  if (props.useBuiltinTranslations) {
130
- const { languageLocale } = useSetupLocale()
131
- void useSetupI18n({
132
- locale: languageLocale,
133
- useBuiltinTranslations: true,
134
- useDummyMessageSetWhileLoading: true,
135
- })
106
+ const { languageLocale } = useSetupLocale();
107
+ void useSetupI18n({
108
+ locale: languageLocale,
109
+ useBuiltinTranslations: true,
110
+ useDummyMessageSetWhileLoading: true
111
+ });
136
112
  }
137
-
138
113
  </script>
139
-
@@ -0,0 +1,41 @@
1
+ import { type Theme } from "metamorphosis";
2
+ import { NotificationHandler } from "../../helpers/NotificationHandler.js.js";
3
+ type __VLS_Props = {
4
+ theme?: Theme;
5
+ outline?: boolean;
6
+ forceOutline?: boolean;
7
+ testWrapperMode?: boolean;
8
+ id?: string;
9
+ /** You can set a ref to the root element by passing :getRef="_ => el = _" */
10
+ getRef?: (el: HTMLElement | null) => void;
11
+ /** True by default, should be passed import.meta.client if using nuxt, or false when running server side. */
12
+ isClientSide?: boolean;
13
+ useBuiltinTranslations?: boolean;
14
+ useNotifications?: boolean;
15
+ notificationHandler?: NotificationHandler;
16
+ };
17
+ declare var __VLS_9: {};
18
+ type __VLS_Slots = {} & {
19
+ default?: (props: typeof __VLS_9) => any;
20
+ };
21
+ declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {
22
+ darkMode: import("../../composables/useDarkMode.js.js").DarkModeState & import("../../composables/useDarkMode.js.js").DarkModeCommands;
23
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
24
+ theme: Theme;
25
+ id: string;
26
+ useBuiltinTranslations: boolean;
27
+ isClientSide: boolean;
28
+ outline: boolean;
29
+ forceOutline: boolean;
30
+ testWrapperMode: boolean;
31
+ getRef: (el: HTMLElement | null) => void;
32
+ useNotifications: boolean;
33
+ notificationHandler: NotificationHandler;
34
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
35
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
36
+ export default _default;
37
+ type __VLS_WithSlots<T, S> = T & {
38
+ new (): {
39
+ $slots: S;
40
+ };
41
+ };
@@ -1,7 +1,8 @@
1
1
  <template>
2
2
  <input
3
3
  :id="id ?? fallbackId"
4
- :class="twMerge(`
4
+ :class="twMerge(
5
+ `
5
6
  simple-input
6
7
  flex-1
7
8
  grow-[999999]
@@ -27,24 +28,24 @@
27
28
  dark:disabled:bg-neutral-950
28
29
  dark:disabled:text-neutral-500
29
30
  `,
30
- type === `text` && `
31
+ type === `text` && `
31
32
  min-w-[10ch]
32
33
  w-full
33
34
  `,
34
- type === `number` && `
35
+ type === `number` && `
35
36
  w-12
36
37
  placeholder:text-transparent
37
38
  appearance-none
38
39
  pr-0
39
40
  `,
40
- border && `
41
+ border && `
41
42
  border
42
43
  border-neutral-500
43
44
  focus:border-accent-500
44
45
  disabled:border-neutral-400
45
46
  dark:disabled:border-neutral-600
46
47
  `,
47
- !valid && `
48
+ !valid && `
48
49
  placeholder:text-danger-700
49
50
  border-danger-700
50
51
  focus:border-danger-700
@@ -54,8 +55,8 @@
54
55
  dark:placeholder:text-danger-700
55
56
  dark:border-danger-600
56
57
  `,
57
- ($attrs as any)?.class
58
- )"
58
+ $attrs?.class
59
+ )"
59
60
  :data-border="border"
60
61
  :data-invalid="!valid"
61
62
  :type="type"
@@ -63,83 +64,47 @@
63
64
  :disabled="disabled"
64
65
  :readonly="readonly"
65
66
  v-model="modelValue"
66
- v-bind="{...$attrs, class:undefined, ...ariaLabel}"
67
+ v-bind="{ ...$attrs, class: void 0, ...ariaLabel }"
67
68
  @keydown="handleKeydown"
68
- @input="emit('input', $event as InputEvent)"
69
+ @input="emit('input', $event)"
69
70
  >
70
71
  </template>
71
72
 
72
-
73
- <script lang="ts" setup generic="T">
74
- import { type InputHTMLAttributes, useAttrs } from "vue"
75
-
76
- import { useAriaLabel } from "../../composables/useAriaLabel.js"
77
- import { usePreHydrationValue } from "../../composables/usePreHydrationValue.js"
78
- import { hasModifiers } from "../../helpers/hasModifiers.js"
79
- import { twMerge } from "../../utils/twMerge.js"
80
- import { type BaseInteractiveProps, baseInteractivePropsDefaults, getFallbackId,type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js"
81
-
82
-
73
+ <script setup>
74
+ import { useAttrs } from "vue";
75
+ import { useAriaLabel } from "../../composables/useAriaLabel.js";
76
+ import { usePreHydrationValue } from "../../composables/usePreHydrationValue.js";
77
+ import { hasModifiers } from "../../helpers/hasModifiers.js";
78
+ import { twMerge } from "../../utils/twMerge.js";
79
+ import { getFallbackId } from "../shared/props.js";
83
80
  defineOptions({
84
- name: "lib-simple-input",
85
- inheritAttrs: false,
86
- })
87
-
88
- const fallbackId = getFallbackId()
89
-
90
- const props = withDefaults(defineProps<Props>(), {
91
- id: "",
92
- placeholder: "",
93
- valid: true,
94
- label: "",
95
- type: undefined,
96
- ...baseInteractivePropsDefaults
97
- })
98
-
99
- const modelValue = defineModel<T>({ required: true })
100
-
101
- const emit = defineEmits<{
102
- /* User presses enter.*/
103
- (e: "submit", val: T): void
104
- (e: "input", val: InputEvent): void
105
- }>()
106
- const $attrs = useAttrs()
107
- const ariaLabel = useAriaLabel(props, fallbackId)
108
-
109
- function handleKeydown(e: KeyboardEvent) {
110
- if (e.key === "Enter" && !hasModifiers(e)) {
111
- emit("submit", modelValue.value)
112
- }
81
+ name: "lib-simple-input",
82
+ inheritAttrs: false
83
+ });
84
+ const fallbackId = getFallbackId();
85
+ const props = defineProps({
86
+ id: { type: String, required: false, default: "" },
87
+ label: { type: String, required: false, default: "" },
88
+ disabled: { type: Boolean, required: false, default: false },
89
+ readonly: { type: Boolean, required: false, default: false },
90
+ border: { type: Boolean, required: false, default: true },
91
+ unstyle: { type: Boolean, required: false, default: false },
92
+ placeholder: { type: null, required: false, default: "" },
93
+ type: { type: null, required: false, default: void 0 },
94
+ valid: { type: Boolean, required: false, default: true }
95
+ });
96
+ const modelValue = defineModel({ type: null, ...{ required: true } });
97
+ const emit = defineEmits(["submit", "input"]);
98
+ const $attrs = useAttrs();
99
+ const ariaLabel = useAriaLabel(props, fallbackId);
100
+ function handleKeydown(e) {
101
+ if (e.key === "Enter" && !hasModifiers(e)) {
102
+ emit("submit", modelValue.value);
103
+ }
113
104
  }
114
- usePreHydrationValue(props.id ?? fallbackId, modelValue)
115
-
105
+ usePreHydrationValue(props.id ?? fallbackId, modelValue);
116
106
  </script>
117
107
 
118
- <script lang="ts">
119
-
120
- type RealProps =
121
- & LinkableByIdProps
122
- & LabelProps
123
- & BaseInteractiveProps
124
- & {
125
- placeholder?: InputHTMLAttributes["placeholder"]
126
- disabled?: InputHTMLAttributes["disabled"]
127
- id?: InputHTMLAttributes["id"]
128
- type?: InputHTMLAttributes["type"]
129
- valid?: boolean
130
- }
108
+ <script>
131
109
 
132
- interface Props
133
- extends
134
- /** @vue-ignore */
135
- Partial<Omit<
136
- InputHTMLAttributes,
137
- | "class"
138
- | "readonly"
139
- | "disabled"
140
- | "onSubmit"
141
- | "onInput"
142
- > & TailwindClassProp>,
143
- RealProps
144
- {}
145
110
  </script>
@@ -0,0 +1,35 @@
1
+ import { type InputHTMLAttributes } from "vue";
2
+ import { type BaseInteractiveProps, type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js.js";
3
+ type RealProps = LinkableByIdProps & LabelProps & BaseInteractiveProps & {
4
+ placeholder?: InputHTMLAttributes["placeholder"];
5
+ disabled?: InputHTMLAttributes["disabled"];
6
+ id?: InputHTMLAttributes["id"];
7
+ type?: InputHTMLAttributes["type"];
8
+ valid?: boolean;
9
+ };
10
+ interface Props extends
11
+ /** @vue-ignore */
12
+ Partial<Omit<InputHTMLAttributes, "class" | "readonly" | "disabled" | "onSubmit" | "onInput"> & TailwindClassProp>, RealProps {
13
+ }
14
+ declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
15
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
16
+ readonly onInput?: ((val: InputEvent) => any) | undefined;
17
+ readonly onSubmit?: ((val: T) => any) | undefined;
18
+ readonly "onUpdate:modelValue"?: ((value: T) => any) | undefined;
19
+ } & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, "onInput" | "onSubmit" | "onUpdate:modelValue"> & (Props & {
20
+ modelValue: T;
21
+ }) & Partial<{}>> & import("vue").PublicProps;
22
+ expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
23
+ attrs: any;
24
+ slots: {};
25
+ emit: {
26
+ (e: "submit", val: T): void;
27
+ (e: "input", val: InputEvent): void;
28
+ } & ((evt: "update:modelValue", value: T) => void);
29
+ }>) => import("vue").VNode & {
30
+ __ctx?: Awaited<typeof __VLS_setup>;
31
+ };
32
+ export default _default;
33
+ type __VLS_PrettifyLocal<T> = {
34
+ [K in keyof T as K]: T[K];
35
+ } & {};