@witchcraft/ui 0.2.1-beta.3 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +20 -4
  3. package/dist/runtime/build/WitchcraftUiResolver.d.ts +2 -2
  4. package/dist/runtime/build/generateTheme.js +2 -2
  5. package/dist/runtime/components/Aria/Aria.d.vue.ts +5 -0
  6. package/dist/runtime/components/Aria/Aria.vue +4 -2
  7. package/dist/runtime/components/Aria/Aria.vue.d.ts +1 -1
  8. package/dist/runtime/components/Icon/Icon.d.vue.ts +21 -0
  9. package/dist/runtime/components/Icon/Icon.vue +3 -3
  10. package/dist/runtime/components/Icon/Icon.vue.d.ts +1 -1
  11. package/dist/runtime/components/LibButton/LibButton.d.vue.ts +36 -0
  12. package/dist/runtime/components/LibButton/LibButton.vue +9 -4
  13. package/dist/runtime/components/LibButton/LibButton.vue.d.ts +1 -1
  14. package/dist/runtime/components/LibCheckbox/LibCheckbox.d.vue.ts +42 -0
  15. package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +3 -4
  16. package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +1 -1
  17. package/dist/runtime/components/LibColorInput/LibColorInput.d.vue.ts +63 -0
  18. package/dist/runtime/components/LibColorInput/LibColorInput.vue +15 -8
  19. package/dist/runtime/components/LibColorInput/LibColorInput.vue.d.ts +1 -1
  20. package/dist/runtime/components/LibColorPicker/LibColorPicker.d.vue.ts +61 -0
  21. package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +10 -6
  22. package/dist/runtime/components/LibColorPicker/LibColorPicker.vue.d.ts +1 -1
  23. package/dist/runtime/components/LibColorPicker/utils/truncate.js +1 -1
  24. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.d.vue.ts +22 -0
  25. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +5 -2
  26. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue.d.ts +1 -1
  27. package/dist/runtime/components/LibDatePicker/LibDatePicker.d.vue.ts +40 -0
  28. package/dist/runtime/components/LibDatePicker/LibDatePicker.vue.d.ts +1 -1
  29. package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.d.vue.ts +34 -0
  30. package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue +8 -6
  31. package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue.d.ts +1 -1
  32. package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.d.vue.ts +34 -0
  33. package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +7 -5
  34. package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue.d.ts +1 -1
  35. package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.d.vue.ts +22 -0
  36. package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue.d.ts +1 -1
  37. package/dist/runtime/components/LibDebug/LibDebug.d.vue.ts +32 -0
  38. package/dist/runtime/components/LibDebug/LibDebug.vue +9 -4
  39. package/dist/runtime/components/LibDebug/LibDebug.vue.d.ts +1 -1
  40. package/dist/runtime/components/LibDevOnly/LibDevOnly.d.vue.ts +25 -0
  41. package/dist/runtime/components/LibDevOnly/LibDevOnly.vue +2 -1
  42. package/dist/runtime/components/LibDevOnly/LibDevOnly.vue.d.ts +4 -1
  43. package/dist/runtime/components/LibFileInput/LibFileInput.d.vue.ts +43 -0
  44. package/dist/runtime/components/LibFileInput/LibFileInput.vue +29 -13
  45. package/dist/runtime/components/LibFileInput/LibFileInput.vue.d.ts +2 -2
  46. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.d.vue.ts +165 -0
  47. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +42 -12
  48. package/dist/runtime/components/LibLabel/LibLabel.d.vue.ts +26 -0
  49. package/dist/runtime/components/LibLabel/LibLabel.vue +2 -2
  50. package/dist/runtime/components/LibLabel/LibLabel.vue.d.ts +3 -3
  51. package/dist/runtime/components/LibMultiValues/LibMultiValues.d.vue.ts +29 -0
  52. package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +1 -2
  53. package/dist/runtime/components/LibMultiValues/LibMultiValues.vue.d.ts +2 -2
  54. package/dist/runtime/components/LibNotifications/LibNotification.d.vue.ts +17 -0
  55. package/dist/runtime/components/LibNotifications/LibNotification.vue +19 -8
  56. package/dist/runtime/components/LibNotifications/LibNotifications.d.vue.ts +13 -0
  57. package/dist/runtime/components/LibNotifications/LibNotifications.vue +10 -6
  58. package/dist/runtime/components/LibNotifications/LibNotifications.vue.d.ts +2 -2
  59. package/dist/runtime/components/LibPagination/LibPagination.d.vue.ts +104 -0
  60. package/dist/runtime/components/LibPagination/LibPagination.vue +25 -12
  61. package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +2 -2
  62. package/dist/runtime/components/LibPalette/LibPalette.d.vue.ts +14 -0
  63. package/dist/runtime/components/LibPalette/LibPalette.vue +6 -5
  64. package/dist/runtime/components/LibPalette/LibPalette.vue.d.ts +5 -5
  65. package/dist/runtime/components/LibPopup/LibPopup.d.vue.ts +46 -0
  66. package/dist/runtime/components/LibPopup/LibPopup.vue +6 -4
  67. package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +3 -3
  68. package/dist/runtime/components/LibProgressBar/LibProgressBar.d.vue.ts +41 -0
  69. package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +5 -3
  70. package/dist/runtime/components/LibProgressBar/LibProgressBar.vue.d.ts +9 -9
  71. package/dist/runtime/components/LibRecorder/LibRecorder.d.vue.ts +77 -0
  72. package/dist/runtime/components/LibRecorder/LibRecorder.vue +1 -1
  73. package/dist/runtime/components/LibRecorder/LibRecorder.vue.d.ts +2 -2
  74. package/dist/runtime/components/LibRoot/LibRoot.d.vue.ts +41 -0
  75. package/dist/runtime/components/LibRoot/LibRoot.vue +11 -6
  76. package/dist/runtime/components/LibRoot/LibRoot.vue.d.ts +1 -1
  77. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.d.vue.ts +35 -0
  78. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue +1 -1
  79. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue.d.ts +1 -1
  80. package/dist/runtime/components/LibSuggestions/LibSuggestions.d.vue.ts +94 -0
  81. package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +6 -4
  82. package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +1 -1
  83. package/dist/runtime/components/LibTable/LibTable.d.vue.ts +45 -0
  84. package/dist/runtime/components/LibTable/LibTable.vue +23 -8
  85. package/dist/runtime/components/LibTable/LibTable.vue.d.ts +1 -1
  86. package/dist/runtime/components/Template/NAME.d.vue.ts +17 -0
  87. package/dist/runtime/components/Template/NAME.vue +2 -3
  88. package/dist/runtime/components/Template/NAME.vue.d.ts +1 -1
  89. package/dist/runtime/components/TestControls/TestControls.d.vue.ts +5 -0
  90. package/dist/runtime/components/TestControls/TestControls.vue +4 -2
  91. package/dist/runtime/components/TestControls/TestControls.vue.d.ts +1 -1
  92. package/dist/runtime/composables/useDragWithThreshold.d.ts +1 -1
  93. package/dist/runtime/composables/useInjectedI18n.d.ts +1 -1
  94. package/dist/runtime/composables/useScrollNearContainerEdges.d.ts +1 -1
  95. package/dist/runtime/composables/useSetupI18n.d.ts +1 -1
  96. package/dist/runtime/composables/useSuggestions.d.ts +2 -2
  97. package/dist/runtime/helpers/NotificationHandler.d.ts +1 -1
  98. package/dist/runtime/helpers/base64ToImg.js +2 -2
  99. package/dist/runtime/tailwind/themeConvertionOpts.d.ts +1 -1
  100. package/dist/runtime/types/index.d.ts +1 -1
  101. package/dist/runtime/utils/notifyIfError.d.ts +1 -1
  102. package/package.json +9 -10
  103. package/src/module.ts +41 -33
  104. package/src/runtime/build/WitchcraftUiResolver.ts +3 -3
  105. package/src/runtime/build/generateTheme.ts +3 -2
  106. package/src/runtime/build/unpluginIconViteOptions.ts +1 -1
  107. package/src/runtime/components/Aria/Aria.vue +5 -6
  108. package/src/runtime/components/Focus.stories.ts +11 -12
  109. package/src/runtime/components/Icon/Icon.vue +5 -9
  110. package/src/runtime/components/LibButton/LibButton.stories.ts +21 -22
  111. package/src/runtime/components/LibButton/LibButton.vue +23 -21
  112. package/src/runtime/components/LibCheckbox/LibCheckbox.stories.ts +6 -10
  113. package/src/runtime/components/LibCheckbox/LibCheckbox.vue +17 -19
  114. package/src/runtime/components/LibColorInput/LibColorInput.stories.ts +8 -13
  115. package/src/runtime/components/LibColorInput/LibColorInput.vue +49 -45
  116. package/src/runtime/components/LibColorPicker/LibColorPicker.stories.ts +14 -18
  117. package/src/runtime/components/LibColorPicker/LibColorPicker.vue +50 -52
  118. package/src/runtime/components/LibColorPicker/utils/safeConvertToHsva.ts +1 -2
  119. package/src/runtime/components/LibColorPicker/utils/safeConvertToRgba.ts +1 -2
  120. package/src/runtime/components/LibColorPicker/utils/truncate.ts +1 -2
  121. package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.ts +5 -8
  122. package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +11 -9
  123. package/src/runtime/components/LibDatePicker/LibDatePicker.stories.ts +14 -15
  124. package/src/runtime/components/LibDatePicker/LibDatePicker.vue +1 -2
  125. package/src/runtime/components/LibDatePicker/LibRangeDatePicker.vue +13 -13
  126. package/src/runtime/components/LibDatePicker/LibSingleDatePicker.vue +9 -8
  127. package/src/runtime/components/LibDatePicker/LibTimeZonePicker.vue +2 -1
  128. package/src/runtime/components/LibDatePicker/helpers.ts +0 -2
  129. package/src/runtime/components/LibDebug/LibDebug.stories.ts +11 -15
  130. package/src/runtime/components/LibDebug/LibDebug.vue +14 -11
  131. package/src/runtime/components/LibDevOnly/LibDevOnly.vue +8 -4
  132. package/src/runtime/components/LibFileInput/LibFileInput.stories.ts +12 -15
  133. package/src/runtime/components/LibFileInput/LibFileInput.vue +65 -47
  134. package/src/runtime/components/LibInputDeprecated/LibInputDeprecated.stories.ts +77 -84
  135. package/src/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +73 -48
  136. package/src/runtime/components/LibLabel/LibLabel.stories.ts +4 -8
  137. package/src/runtime/components/LibLabel/LibLabel.vue +8 -8
  138. package/src/runtime/components/LibMultiValues/LibMultiValues.stories.ts +10 -15
  139. package/src/runtime/components/LibMultiValues/LibMultiValues.vue +14 -18
  140. package/src/runtime/components/LibNotifications/LibNotification.stories.ts +30 -34
  141. package/src/runtime/components/LibNotifications/LibNotification.vue +27 -17
  142. package/src/runtime/components/LibNotifications/LibNotifications.stories.ts +11 -15
  143. package/src/runtime/components/LibNotifications/LibNotifications.vue +21 -16
  144. package/src/runtime/components/LibPagination/LibPagination.stories.ts +5 -9
  145. package/src/runtime/components/LibPagination/LibPagination.vue +46 -32
  146. package/src/runtime/components/LibPalette/LibPalette.stories.ts +3 -7
  147. package/src/runtime/components/LibPalette/LibPalette.vue +13 -12
  148. package/src/runtime/components/LibPopup/LibPopup.stories.ts +19 -23
  149. package/src/runtime/components/LibPopup/LibPopup.vue +31 -35
  150. package/src/runtime/components/LibProgressBar/LibProgressBar.stories.ts +13 -17
  151. package/src/runtime/components/LibProgressBar/LibProgressBar.vue +36 -33
  152. package/src/runtime/components/LibRecorder/LibRecorder.stories.ts +11 -12
  153. package/src/runtime/components/LibRecorder/LibRecorder.vue +34 -34
  154. package/src/runtime/components/LibRoot/LibRoot.vue +16 -12
  155. package/src/runtime/components/LibSimpleInput/LibSimpleInput.stories.ts +20 -24
  156. package/src/runtime/components/LibSimpleInput/LibSimpleInput.vue +17 -21
  157. package/src/runtime/components/LibSuggestions/LibSuggestions.stories.ts +16 -19
  158. package/src/runtime/components/LibSuggestions/LibSuggestions.vue +28 -30
  159. package/src/runtime/components/LibTable/LibTable.stories.ts +30 -33
  160. package/src/runtime/components/LibTable/LibTable.vue +38 -24
  161. package/src/runtime/components/Reset.stories.ts +3 -6
  162. package/src/runtime/components/Scrolling.stories.ts +5 -8
  163. package/src/runtime/components/Template/NAME.vue +11 -11
  164. package/src/runtime/components/Template/TemplateStory.ts +9 -10
  165. package/src/runtime/components/TestControls/TestControls.vue +5 -5
  166. package/src/runtime/components/shared/props.ts +4 -6
  167. package/src/runtime/components/shared/storyHelpers/playInput.ts +2 -3
  168. package/src/runtime/components/shared/storyHelpers/playSuggestions.ts +5 -9
  169. package/src/runtime/composables/useAccesibilityOutline.ts +1 -1
  170. package/src/runtime/composables/useAriaLabel.ts +1 -1
  171. package/src/runtime/composables/useDarkMode.ts +15 -19
  172. package/src/runtime/composables/useDragWithThreshold.ts +6 -8
  173. package/src/runtime/composables/useGlobalResizeObserver.ts +0 -1
  174. package/src/runtime/composables/useInjectedDarkMode.ts +2 -2
  175. package/src/runtime/composables/useInjectedI18n.ts +1 -1
  176. package/src/runtime/composables/useInjectedLocale.ts +3 -4
  177. package/src/runtime/composables/useScrollNearContainerEdges.stories.ts +4 -4
  178. package/src/runtime/composables/useScrollNearContainerEdges.ts +12 -13
  179. package/src/runtime/composables/useSetupI18n.ts +4 -7
  180. package/src/runtime/composables/useSetupLocale.ts +3 -5
  181. package/src/runtime/composables/useSuggestions.ts +25 -30
  182. package/src/runtime/directives/vDetectFlex.ts +5 -8
  183. package/src/runtime/directives/vExtractRootEl.ts +1 -1
  184. package/src/runtime/directives/vResizableCols.ts +3 -7
  185. package/src/runtime/directives/vResizeObserver.ts +1 -2
  186. package/src/runtime/globalResizeObserver.ts +0 -1
  187. package/src/runtime/helpers/NotificationHandler.ts +8 -12
  188. package/src/runtime/helpers/base64ToImg.ts +2 -3
  189. package/src/runtime/helpers/createNoonUtcDate.ts +0 -1
  190. package/src/runtime/helpers/defaultTranslationFunction.ts +0 -1
  191. package/src/runtime/helpers/getTimeZoneList.ts +0 -1
  192. package/src/runtime/helpers/readFile.ts +2 -2
  193. package/src/runtime/helpers/resizeObserverWrapper.ts +0 -1
  194. package/src/runtime/helpers/storybook.ts +2 -3
  195. package/src/runtime/main.lib.ts +0 -2
  196. package/src/runtime/nuxt/plugins/vue-plugin.ts +4 -5
  197. package/src/runtime/tailwind/themeConvertionOpts.ts +3 -4
  198. package/src/runtime/theme.ts +0 -1
  199. package/src/runtime/types/index.ts +3 -4
  200. package/src/runtime/utils/notifyIfError.ts +2 -2
  201. package/src/runtime/utils/twMerge.ts +2 -2
  202. package/src/runtime/vue/VueComponentsPlugin.ts +1 -2
  203. package/src/runtime/vue/registerComponents.ts +0 -1
@@ -4,10 +4,8 @@ import { onUnmounted, ref } from "vue"
4
4
 
5
5
  import LibProgressBar from "./LibProgressBar.vue"
6
6
 
7
- // eslint-disable-next-line @typescript-eslint/no-restricted-imports
8
7
  import * as components from "../index.js"
9
8
 
10
-
11
9
  const meta: Meta<typeof LibProgressBar> = {
12
10
  component: LibProgressBar,
13
11
  title: "Components/ProgressBar",
@@ -16,14 +14,13 @@ const meta: Meta<typeof LibProgressBar> = {
16
14
  // @ts-expect-error .
17
15
  _timeout: 1000,
18
16
  _add: 10,
19
- _start: 50,
20
- },
17
+ _start: 50
18
+ }
21
19
  }
22
20
 
23
21
  export default meta
24
22
  type Story = StoryObj<typeof LibProgressBar>
25
23
 
26
-
27
24
  export const Primary: Story = {
28
25
  render: args => ({
29
26
  components,
@@ -45,7 +42,7 @@ export const Primary: Story = {
45
42
  }
46
43
  return {
47
44
  args: { ...args },
48
- progress,
45
+ progress
49
46
  }
50
47
  },
51
48
  template: `
@@ -55,28 +52,28 @@ export const Primary: Story = {
55
52
  <div class="flex w-full">
56
53
  <lib-progress-bar class="flex-1" v-bind="args" :progress="progress"></lib-progress-bar>
57
54
  </div>
58
- `,
59
- }),
55
+ `
56
+ })
60
57
  }
61
58
  export const Secondary: Story = {
62
59
  ...Primary,
63
60
  args: {
64
- ...Primary.args,
65
- },
61
+ ...Primary.args
62
+ }
66
63
  }
67
64
  export const ReallyLongLabel: Story = {
68
65
  ...Primary,
69
66
  args: {
70
67
  ...Primary.args,
71
- label: "Really Long Label Label to See Effect Really Long Label Label to See Effect Really Long Label Label to See Effect Really Long Label Label to See Effect",
72
- },
68
+ label: "Really Long Label Label to See Effect Really Long Label Label to See Effect Really Long Label Label to See Effect Really Long Label Label to See Effect"
69
+ }
73
70
  }
74
71
  export const Static: Story = {
75
72
  ...Primary,
76
73
  args: {
77
74
  ...Primary.args,
78
- progress: 50,
79
- },
75
+ progress: 50
76
+ }
80
77
  }
81
78
 
82
79
  export const AutoHiding: Story = {
@@ -88,7 +85,6 @@ export const AutoHiding: Story = {
88
85
  _start: 0,
89
86
  // keepSpaceWhenHidden: true,
90
87
  _timeout: 1000,
91
- _add: 10,
92
- },
88
+ _add: 10
89
+ }
93
90
  }
94
-
@@ -1,6 +1,7 @@
1
1
  <template>
2
2
  <Transition>
3
- <div v-if="!hide"
3
+ <div
4
+ v-if="!hide"
4
5
  :id="id ?? fallbackId"
5
6
  :class="twMerge(`
6
7
  progress-bar
@@ -35,7 +36,7 @@
35
36
  before:transition-all
36
37
  before:z-1
37
38
  before:duration-500
38
- `,psuedoHide && `
39
+ `, psuedoHide && `
39
40
  after:opacity-0
40
41
  before:opacity-0
41
42
  `, ($attrs as any).class)"
@@ -45,14 +46,15 @@
45
46
  :aria-valuenow="clampVal(progress, clamp[0] ?? 0, clamp[1] ?? 100)"
46
47
  :aria-valuemin="clamp[0] ?? 0"
47
48
  :aria-valuemax="clamp[1] ?? 100"
48
- v-bind="{...$attrs, class:undefined}"
49
+ v-bind="{ ...$attrs, class: undefined }"
49
50
  :style="`--progress: ${clampVal(progress, clamp[0] ?? 0, clamp[1] ?? 100)}%;`"
50
51
  >
51
52
  <div class="procgress-bar--label-wrapper relative flex-1">
52
53
  <span class="before:content-vertical-holder"/>
53
54
  <Transition>
54
55
  <slot>
55
- <label v-if="!psuedoHide"
56
+ <label
57
+ v-if="!psuedoHide"
56
58
  :for="id"
57
59
  class="
58
60
  text-bg
@@ -93,25 +95,26 @@
93
95
  </div>
94
96
  </Transition>
95
97
  </template>
98
+
96
99
  <script setup lang="ts">
97
- import { type HTMLAttributes,type PropType, ref, watch } from "vue"
100
+ import { ref, watch } from "vue"
98
101
 
99
102
  import { twMerge } from "../../utils/twMerge.js"
100
- import { type BaseInteractiveProps,getFallbackId,type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js"
103
+ import { type BaseInteractiveProps, getFallbackId, type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js"
101
104
 
102
105
  // TODO move to utils
103
106
  const clampVal = (n: number, min: number, max: number) => Math.min(Math.max(n, min), max)
104
107
 
105
108
  defineOptions({
106
- name: "lib-progress-bar",
107
- inheritAttrs: false,
109
+ name: "LibProgressBar",
110
+ inheritAttrs: false
108
111
  })
109
112
  const fallbackId = getFallbackId()
110
113
  const props = withDefaults(defineProps<Props>(), {
111
114
  autohideOnComplete: -1,
112
115
  keepSpaceWhenHidden: false,
113
116
  clamp: () => [0, 100],
114
- unstyle: false, disabled: false, readonly: false, border: true,
117
+ unstyle: false, disabled: false, readonly: false, border: true
115
118
  })
116
119
  const hide = ref<boolean>(false)
117
120
  const psuedoHide = ref<boolean>(false)
@@ -130,7 +133,7 @@ if (props.autohideOnComplete > -1 && (props.progress >= 100 || props.progress <
130
133
  watch([
131
134
  () => props.progress,
132
135
  () => props.keepSpaceWhenHidden,
133
- () => props.autohideOnComplete,
136
+ () => props.autohideOnComplete
134
137
  ], () => {
135
138
  if (props.autohideOnComplete > -1 && (props.progress >= 100 || props.progress < 0)) {
136
139
  if (props.keepSpaceWhenHidden) {
@@ -158,36 +161,36 @@ watch([
158
161
  psuedoHide.value = false
159
162
  }
160
163
  }, { immediate: false })
161
-
162
164
  </script>
165
+
163
166
  <script lang="ts">
167
+ import type { HTMLAttributes } from "vue"
164
168
 
165
- type RealProps =
166
- & LinkableByIdProps
167
- & BaseInteractiveProps
168
- & LabelProps
169
- & {
170
- progress: number
171
- /** Will auto hide after this given time if progress is 100% or more or less than 0% until progress is set to something else. Disabled (-1) by default. */
172
- autohideOnComplete?: number
173
- /**
174
- * Do not actually hide the element, just leave an unstyled div,
175
- * so the whole layout doesn't change on completion when autohideOnComplete is set.
176
- */
177
- keepSpaceWhenHidden?: boolean
178
- /**
179
- * By default the progress bar is visually clamped to 0-100, even if the value might be something else.
180
- * You can change what it's clamped to here, to for example,
181
- * show at least a small sliver of the progress bar when it's still 0.
182
- */
183
- clamp?: [start:number, end:number]
184
- }
169
+ type RealProps
170
+ = & LinkableByIdProps
171
+ & BaseInteractiveProps
172
+ & LabelProps
173
+ & {
174
+ progress: number
175
+ /** Will auto hide after this given time if progress is 100% or more or less than 0% until progress is set to something else. Disabled (-1) by default. */
176
+ autohideOnComplete?: number
177
+ /**
178
+ * Do not actually hide the element, just leave an unstyled div,
179
+ * so the whole layout doesn't change on completion when autohideOnComplete is set.
180
+ */
181
+ keepSpaceWhenHidden?: boolean
182
+ /**
183
+ * By default the progress bar is visually clamped to 0-100, even if the value might be something else.
184
+ * You can change what it's clamped to here, to for example,
185
+ * show at least a small sliver of the progress bar when it's still 0.
186
+ */
187
+ clamp?: [start: number, end: number]
188
+ }
185
189
 
186
190
  interface Props
187
191
  extends
188
192
  /** @vue-ignore */
189
- Partial<Omit<HTMLAttributes,"class"> & TailwindClassProp>,
193
+ Partial<Omit<HTMLAttributes, "class"> & TailwindClassProp>,
190
194
  RealProps
191
195
  { }
192
-
193
196
  </script>
@@ -3,7 +3,6 @@ import type { Meta, StoryObj } from "@storybook/vue3"
3
3
  import { ref, watchEffect } from "vue"
4
4
 
5
5
  import { createRecorderHandler, createRecorderWatchEffect } from "../../helpers/storybook.js"
6
- // eslint-disable-next-line @typescript-eslint/no-restricted-imports
7
6
  import * as components from "../index.js"
8
7
  /**
9
8
  * This is a special input component designed to record any type of event.
@@ -18,8 +17,8 @@ const meta: Meta<typeof components.LibRecorder> = {
18
17
  args: {
19
18
  label: "Some Label",
20
19
  recordingTitle: "Recording. Press enter or click away to accept. Press escape to cancel.",
21
- modelValue: "K E Y S",
22
- },
20
+ modelValue: "K E Y S"
21
+ }
23
22
  }
24
23
 
25
24
  export default meta
@@ -41,7 +40,7 @@ export const Primary: Story = {
41
40
  recorder,
42
41
  recording,
43
42
  recordingValue,
44
- recorderEl,
43
+ recorderEl
45
44
  }
46
45
  },
47
46
  template: `
@@ -54,28 +53,28 @@ export const Primary: Story = {
54
53
  v-model="modelValue"
55
54
  @recorder:click="recording = !recording"
56
55
  />
57
- `,
58
- }),
56
+ `
57
+ })
59
58
  }
60
59
 
61
60
  /** Should not be tabbable or recordable. */
62
61
  export const Disabled: Story = {
63
62
  ...Primary,
64
63
  args: {
65
- disabled: true,
66
- },
64
+ disabled: true
65
+ }
67
66
  }
68
67
  /** *Should* be tabbable but not recordable. */
69
68
  export const Readonly: Story = {
70
69
  ...Primary,
71
70
  args: {
72
- readonly: true,
73
- },
71
+ readonly: true
72
+ }
74
73
  }
75
74
  /** Height should not shrink. */
76
75
  export const EmptyInitialValue: Story = {
77
76
  ...Primary,
78
77
  args: {
79
- modelValue: "",
80
- },
78
+ modelValue: ""
79
+ }
81
80
  }
@@ -28,15 +28,15 @@
28
28
  dark:bg-neutral-950
29
29
  border-neutral-400
30
30
  dark:border-neutral-600
31
- `
32
- , ($attrs as any).class)"
31
+ `,
32
+ ($attrs as any).class)"
33
33
  :aria-disabled="disabled"
34
34
  :aria-readonly="readonly"
35
35
  :tabindex="disabled ? -1 : 0"
36
36
  :title="recording ? recordingTitle : tempValue"
37
37
  contenteditable="false"
38
38
  ref="recorderEl"
39
- v-bind="{...ariaLabel, ...$attrs, class:undefined}"
39
+ v-bind="{ ...ariaLabel, ...$attrs, class: undefined }"
40
40
  @blur="handleBlurRecorder($event)"
41
41
  @click="handleClickRecorder($event)"
42
42
  @keydown.space.prevent="handleClickRecorder($event, true)"
@@ -69,18 +69,19 @@
69
69
  </div>
70
70
  </div>
71
71
  </template>
72
+
72
73
  <script setup lang="ts">
73
74
  import { keys } from "@alanscodelog/utils/keys"
74
- import { computed, type HTMLAttributes ,onBeforeUnmount, onMounted, type PropType, ref, watch, watchPostEffect } from "vue"
75
+ import { computed, type HTMLAttributes, onBeforeUnmount, onMounted, ref, watch, watchPostEffect } from "vue"
75
76
 
76
77
  import { useAriaLabel } from "../../composables/useAriaLabel.js"
77
78
  import { useInjectedI18n } from "../../composables/useInjectedI18n.js"
78
79
  import { twMerge } from "../../utils/twMerge.js"
79
- import { type BaseInteractiveProps, getFallbackId, type LabelProps, type LinkableByIdProps,type TailwindClassProp } from "../shared/props.js"
80
+ import { type BaseInteractiveProps, getFallbackId, type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js"
80
81
 
81
82
  defineOptions({
82
- name: "lib-recorder",
83
- inheritAttrs: false,
83
+ name: "LibRecorder",
84
+ inheritAttrs: false
84
85
  })
85
86
  const t = useInjectedI18n()
86
87
 
@@ -98,7 +99,7 @@ const props = withDefaults(defineProps<Props>(), {
98
99
  id: undefined,
99
100
  binders: undefined,
100
101
  recorder: undefined,
101
- unstyle: false, disabled: false, readonly: false, border: true,
102
+ unstyle: false, disabled: false, readonly: false, border: true
102
103
  })
103
104
  /**
104
105
  * Puts the element into recording mode if true. See {@link props.recorder}.
@@ -108,7 +109,6 @@ const recording = defineModel<boolean>("recording", { required: false, default:
108
109
  /** The final value of the recorder. For intermediate values while recording, pass a recorder and set an appropriate recording value. */
109
110
  const modelValue = defineModel<string>({ required: true })
110
111
 
111
-
112
112
  const recorderEl = ref<HTMLInputElement | null>(null)
113
113
  const recorderIndicatorEl = ref<HTMLElement | null>(null)
114
114
  const canEdit = computed(() => !props.disabled && !props.readonly)
@@ -206,37 +206,37 @@ const handleClickRecorder = (e: MouseEvent | KeyboardEvent, isSpaceKey: boolean
206
206
  emits("recorder:click", { event: e as MouseEvent, indicator: recorderIndicatorEl.value! as HTMLElement, input: recorderEl.value! as HTMLInputElement })
207
207
  }
208
208
  }
209
-
210
209
  </script>
210
+
211
211
  <script lang="ts">
212
- type RealProps =
213
- & LinkableByIdProps
214
- & BaseInteractiveProps
215
- & LabelProps
216
- & {
217
- border?: boolean
218
- /** A value to display while recording, if none given the i18n `recorder.recording` key is used. */
219
- recordingValue?: string
220
- /** A title to display on the input div while recording. Is also used as the aria-description. */
221
- recordingTitle?: string
222
- /**
223
- * 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.
224
- *
225
- * The listeners are then unbound when recording is set to false again.
226
- *
227
- * 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.
228
- */
229
- recorder?: undefined | Record<string, any>
230
- /** 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.*/
231
- binders?: undefined | { bind: (el: HTMLElement) => void, unbind: (el: HTMLElement) => void }
232
- /** The id of the element. If not provided, the id will be generated automatically. */
233
- id?: string
234
- }
212
+ type RealProps
213
+ = & LinkableByIdProps
214
+ & BaseInteractiveProps
215
+ & LabelProps
216
+ & {
217
+ border?: boolean
218
+ /** A value to display while recording, if none given the i18n `recorder.recording` key is used. */
219
+ recordingValue?: string
220
+ /** A title to display on the input div while recording. Is also used as the aria-description. */
221
+ recordingTitle?: string
222
+ /**
223
+ * 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.
224
+ *
225
+ * The listeners are then unbound when recording is set to false again.
226
+ *
227
+ * 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.
228
+ */
229
+ recorder?: undefined | Record<string, any>
230
+ /** 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. */
231
+ binders?: undefined | { bind: (el: HTMLElement) => void, unbind: (el: HTMLElement) => void }
232
+ /** The id of the element. If not provided, the id will be generated automatically. */
233
+ id?: string
234
+ }
235
235
 
236
236
  interface Props
237
237
  extends
238
238
  /** @vue-ignore */
239
- Partial<Omit<HTMLAttributes,"class"> & TailwindClassProp>,
239
+ Partial<Omit<HTMLAttributes, "class"> & TailwindClassProp>,
240
240
  RealProps
241
241
  { }
242
242
  </script>
@@ -1,12 +1,13 @@
1
1
  <template>
2
- <div :id="id"
2
+ <div
3
+ :id="id"
3
4
  tabindex="-1"
4
5
  :class="twMerge(
5
6
  (showOutline ? 'group outlined outlined-visible' : '[&_*]:outline-hidden'),
6
7
  darkMode && ' dark',
7
8
  ($attrs['wrapperAttrs'] as any)?.class
8
9
  )"
9
- v-bind="{ ...($attrs['wrapperAttrs']), attrs:undefined, class: undefined }"
10
+ v-bind="{ ...($attrs['wrapperAttrs']), attrs: undefined, class: undefined }"
10
11
  :ref="handleRef"
11
12
  >
12
13
  <!-- id root is useful for teleports, so they are at the topmost level where they can still be styled -->
@@ -14,7 +15,7 @@
14
15
  <div
15
16
  id="root"
16
17
  v-bind="{ ...$attrs.attrs, class: undefined, wrapperAttrs: undefined }"
17
- :class="twMerge( `
18
+ :class="twMerge(`
18
19
  dark:bg-fg
19
20
  dark:text-bg
20
21
  bg-bg
@@ -31,9 +32,14 @@
31
32
  `,
32
33
  ($attrs as any).attrs?.class)"
33
34
  >
34
- <TestControls v-if="testWrapperMode" :show-outline="showOutline"/>
35
- <!-- @vue-expect-error data-allow-mismatch is for vue/nuxt to allow the hydration mismatch-->
36
- <Notifications v-if="useNotifications && isClientSide" data-allow-mismatch/>
35
+ <TestControls
36
+ v-if="testWrapperMode"
37
+ :show-outline="showOutline"
38
+ />
39
+ <Notifications
40
+ v-if="useNotifications && isClientSide"
41
+ data-allow-mismatch
42
+ />
37
43
  <slot/>
38
44
  </div>
39
45
  </div>
@@ -41,7 +47,7 @@
41
47
 
42
48
  <script setup lang="ts">
43
49
  import { unreachable } from "@alanscodelog/utils/unreachable"
44
- import { type Theme } from "metamorphosis"
50
+ import type { Theme } from "metamorphosis"
45
51
  import { type ComponentPublicInstance, computed, onBeforeUnmount, onMounted, ref, toRaw } from "vue"
46
52
 
47
53
  import { useAccesibilityOutline } from "../../composables/useAccesibilityOutline.js"
@@ -59,7 +65,7 @@ import TestControls from "../TestControls/TestControls.vue"
59
65
 
60
66
  const $attrs = useDivideAttrs(["wrapper"])
61
67
 
62
- defineOptions({ name: "root", inheritAttrs: false, suspensible: false })
68
+ defineOptions({ name: "Root", inheritAttrs: false, suspensible: false })
63
69
  const props = withDefaults(defineProps<{
64
70
  theme?: Theme
65
71
  outline?: boolean
@@ -124,7 +130,7 @@ const darkMode = darkModeSetup.darkMode
124
130
  useShowDevOnlyKey()
125
131
 
126
132
  defineExpose({
127
- darkMode: darkModeSetup,
133
+ darkMode: darkModeSetup
128
134
  })
129
135
 
130
136
  if (props.useBuiltinTranslations) {
@@ -132,9 +138,7 @@ if (props.useBuiltinTranslations) {
132
138
  void useSetupI18n({
133
139
  locale: languageLocale,
134
140
  useBuiltinTranslations: true,
135
- useDummyMessageSetWhileLoading: true,
141
+ useDummyMessageSetWhileLoading: true
136
142
  })
137
143
  }
138
-
139
144
  </script>
140
-
@@ -1,27 +1,24 @@
1
1
  /* eslint-disable @typescript-eslint/naming-convention */
2
2
  import type { Meta, StoryObj } from "@storybook/vue3"
3
3
 
4
- // eslint-disable-next-line @typescript-eslint/no-restricted-imports
5
4
  import * as components from "../index.js"
6
5
 
7
-
8
6
  const meta = {
9
7
  component: components.LibSimpleInput,
10
8
  title: "Components/Input",
11
9
  args: {
12
10
  modelValue: "Value",
13
- placeholder: "Placeholder",
14
- },
11
+ placeholder: "Placeholder"
12
+ }
15
13
  } satisfies Meta<typeof components.LibSimpleInput> & Meta<{ custom: string }>
16
14
 
17
15
  export default meta
18
16
  type Story = StoryObj<typeof components.LibSimpleInput> // & StoryObj<typeof extraArgs>
19
17
 
20
-
21
18
  /** Input */
22
19
  export const Primary: Story = {
23
20
  args: {
24
- modelValue: "some value",
21
+ modelValue: "some value"
25
22
  },
26
23
  render: args => ({
27
24
  components,
@@ -32,8 +29,8 @@ export const Primary: Story = {
32
29
  @keydown="test"
33
30
  class="m-2" v-bind="args" v-model="args.modelValue" ></lib-simple-input>
34
31
  <lib-simple-input class="m-2" v-bind="{...args, modelValue:''}" ></lib-simple-input>
35
- `,
36
- }),
32
+ `
33
+ })
37
34
  }
38
35
 
39
36
  /** Has more reasonable min-width inside a flexbox. */
@@ -47,31 +44,30 @@ export const InsideAFlexbox: Story = {
47
44
  <lib-simple-input v-bind="args" v-model="args.modelValue"></lib-simple-input>
48
45
  <div class="border-1 border-danger-500 flex-1 whitespace-nowrap">Flex Grow: 1</div>
49
46
  </div>
50
- `,
47
+ `
51
48
  }),
52
49
  args: {
53
- stretch: true,
54
- },
50
+ stretch: true
51
+ }
55
52
  }
56
53
 
57
-
58
54
  export const Disabled = {
59
55
  ...Primary,
60
56
  args: {
61
- disabled: true,
62
- },
57
+ disabled: true
58
+ }
63
59
  }
64
60
  export const Readonly = {
65
61
  ...Primary,
66
62
  args: {
67
- readonly: true,
68
- },
63
+ readonly: true
64
+ }
69
65
  }
70
66
  export const Invalid = {
71
67
  ...Primary,
72
68
  args: {
73
- valid: false,
74
- },
69
+ valid: false
70
+ }
75
71
  }
76
72
  /**
77
73
  * Intended for being wrapped.
@@ -80,19 +76,19 @@ export const Invalid = {
80
76
  export const Borderless = {
81
77
  ...Primary,
82
78
  args: {
83
- border: false,
84
- },
79
+ border: false
80
+ }
85
81
  }
86
82
 
87
83
  export const Numerical = {
88
84
  ...Primary,
89
85
  args: {
90
- type: "number",
91
- },
86
+ type: "number"
87
+ }
92
88
  }
93
89
  export const NumericalInsideAFlexbox = {
94
90
  ...InsideAFlexbox,
95
91
  args: {
96
- type: "number",
97
- },
92
+ type: "number"
93
+ }
98
94
  }
@@ -63,13 +63,12 @@
63
63
  :disabled="disabled"
64
64
  :readonly="readonly"
65
65
  v-model="modelValue"
66
- v-bind="{...$attrs, class:undefined, ...ariaLabel}"
66
+ v-bind="{ ...$attrs, class: undefined, ...ariaLabel }"
67
67
  @keydown="handleKeydown"
68
68
  @input="emit('input', $event as InputEvent)"
69
69
  >
70
70
  </template>
71
71
 
72
-
73
72
  <script lang="ts" setup generic="T">
74
73
  import { type InputHTMLAttributes, useAttrs } from "vue"
75
74
 
@@ -77,12 +76,11 @@ import { useAriaLabel } from "../../composables/useAriaLabel.js"
77
76
  import { usePreHydrationValue } from "../../composables/usePreHydrationValue.js"
78
77
  import { hasModifiers } from "../../helpers/hasModifiers.js"
79
78
  import { twMerge } from "../../utils/twMerge.js"
80
- import { type BaseInteractiveProps, getFallbackId,type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js"
81
-
79
+ import { type BaseInteractiveProps, getFallbackId, type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js"
82
80
 
83
81
  defineOptions({
84
- name: "lib-simple-input",
85
- inheritAttrs: false,
82
+ name: "LibSimpleInput",
83
+ inheritAttrs: false
86
84
  })
87
85
 
88
86
  const fallbackId = getFallbackId()
@@ -93,13 +91,13 @@ const props = withDefaults(defineProps<Props>(), {
93
91
  valid: true,
94
92
  label: "",
95
93
  type: undefined,
96
- unstyle: false, disabled: false, readonly: false, border: true,
94
+ unstyle: false, disabled: false, readonly: false, border: true
97
95
  })
98
96
 
99
97
  const modelValue = defineModel<T>({ required: true })
100
98
 
101
99
  const emit = defineEmits<{
102
- /* User presses enter.*/
100
+ /* User presses enter. */
103
101
  (e: "submit", val: T): void
104
102
  (e: "input", val: InputEvent): void
105
103
  }>()
@@ -112,22 +110,20 @@ function handleKeydown(e: KeyboardEvent) {
112
110
  }
113
111
  }
114
112
  usePreHydrationValue(props.id ?? fallbackId, modelValue)
115
-
116
113
  </script>
117
114
 
118
115
  <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
- }
116
+ type RealProps
117
+ = & LinkableByIdProps
118
+ & LabelProps
119
+ & BaseInteractiveProps
120
+ & {
121
+ placeholder?: InputHTMLAttributes["placeholder"]
122
+ disabled?: InputHTMLAttributes["disabled"]
123
+ id?: InputHTMLAttributes["id"]
124
+ type?: InputHTMLAttributes["type"]
125
+ valid?: boolean
126
+ }
131
127
 
132
128
  interface Props
133
129
  extends