@witchcraft/ui 0.1.1 → 0.1.3

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 (122) hide show
  1. package/dist/module.cjs +5 -0
  2. package/dist/module.d.ts +36 -0
  3. package/dist/module.json +2 -2
  4. package/dist/module.mjs +2 -1
  5. package/dist/runtime/assets/utils.css +1 -1
  6. package/dist/runtime/components/Aria/Aria.vue +9 -5
  7. package/dist/runtime/components/Focus.stories.d.ts +11 -0
  8. package/dist/runtime/components/Focus.stories.js +53 -0
  9. package/dist/runtime/components/Icon/Icon.vue +30 -10
  10. package/dist/runtime/components/LibButton/LibButton.stories.d.ts +12 -0
  11. package/dist/runtime/components/LibButton/LibButton.stories.js +94 -0
  12. package/dist/runtime/components/LibButton/LibButton.vue +72 -58
  13. package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.d.ts +14 -0
  14. package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.js +29 -0
  15. package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +74 -48
  16. package/dist/runtime/components/LibColorInput/LibColorInput.stories.d.ts +7 -0
  17. package/dist/runtime/components/LibColorInput/LibColorInput.stories.js +58 -0
  18. package/dist/runtime/components/LibColorInput/LibColorInput.vue +107 -63
  19. package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.d.ts +9 -0
  20. package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.js +68 -0
  21. package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +352 -271
  22. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.d.ts +7 -0
  23. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.js +36 -0
  24. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +56 -32
  25. package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.d.ts +11 -0
  26. package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.js +98 -0
  27. package/dist/runtime/components/LibDatePicker/LibDatePicker.vue +38 -17
  28. package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue +82 -53
  29. package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +67 -50
  30. package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue +8 -7
  31. package/dist/runtime/components/LibDebug/LibDebug.stories.d.ts +9 -0
  32. package/dist/runtime/components/LibDebug/LibDebug.stories.js +46 -0
  33. package/dist/runtime/components/LibDebug/LibDebug.vue +70 -42
  34. package/dist/runtime/components/LibDevOnly/LibDevOnly.vue +31 -18
  35. package/dist/runtime/components/LibFileInput/LibFileInput.stories.d.ts +10 -0
  36. package/dist/runtime/components/LibFileInput/LibFileInput.stories.js +63 -0
  37. package/dist/runtime/components/LibFileInput/LibFileInput.vue +156 -113
  38. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.stories.d.ts +33 -0
  39. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.stories.js +384 -0
  40. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +241 -215
  41. package/dist/runtime/components/LibLabel/LibLabel.stories.d.ts +6 -0
  42. package/dist/runtime/components/LibLabel/LibLabel.stories.js +25 -0
  43. package/dist/runtime/components/LibLabel/LibLabel.vue +46 -30
  44. package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.d.ts +23 -0
  45. package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.js +61 -0
  46. package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +58 -44
  47. package/dist/runtime/components/LibNotifications/LibNotification.stories.d.ts +15 -0
  48. package/dist/runtime/components/LibNotifications/LibNotification.stories.js +126 -0
  49. package/dist/runtime/components/LibNotifications/LibNotification.vue +48 -32
  50. package/dist/runtime/components/LibNotifications/LibNotifications.stories.d.ts +6 -0
  51. package/dist/runtime/components/LibNotifications/LibNotifications.stories.js +109 -0
  52. package/dist/runtime/components/LibNotifications/LibNotifications.vue +83 -63
  53. package/dist/runtime/components/LibPagination/LibPagination.stories.d.ts +6 -0
  54. package/dist/runtime/components/LibPagination/LibPagination.stories.js +40 -0
  55. package/dist/runtime/components/LibPagination/LibPagination.vue +111 -67
  56. package/dist/runtime/components/LibPalette/LibPalette.stories.d.ts +6 -0
  57. package/dist/runtime/components/LibPalette/LibPalette.stories.js +20 -0
  58. package/dist/runtime/components/LibPalette/LibPalette.vue +23 -20
  59. package/dist/runtime/components/LibPopup/LibPopup.stories.d.ts +14 -0
  60. package/dist/runtime/components/LibPopup/LibPopup.stories.js +147 -0
  61. package/dist/runtime/components/LibPopup/LibPopup.vue +351 -314
  62. package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.d.ts +10 -0
  63. package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.js +81 -0
  64. package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +91 -70
  65. package/dist/runtime/components/LibRecorder/LibRecorder.stories.d.ts +19 -0
  66. package/dist/runtime/components/LibRecorder/LibRecorder.stories.js +63 -0
  67. package/dist/runtime/components/LibRecorder/LibRecorder.vue +177 -133
  68. package/dist/runtime/components/LibRoot/LibRoot.vue +100 -73
  69. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.d.ts +26 -0
  70. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.js +78 -0
  71. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue +77 -49
  72. package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.d.ts +27 -0
  73. package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.js +112 -0
  74. package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +156 -123
  75. package/dist/runtime/components/LibTable/LibTable.stories.d.ts +16 -0
  76. package/dist/runtime/components/LibTable/LibTable.stories.js +156 -0
  77. package/dist/runtime/components/LibTable/LibTable.vue +99 -63
  78. package/dist/runtime/components/Reset.stories.d.ts +5 -0
  79. package/dist/runtime/components/Reset.stories.js +19 -0
  80. package/dist/runtime/components/Scrolling.stories.d.ts +6 -0
  81. package/dist/runtime/components/Scrolling.stories.js +44 -0
  82. package/dist/runtime/components/Template/NAME.vue +36 -15
  83. package/dist/runtime/components/TestControls/TestControls.vue +9 -6
  84. package/dist/runtime/composables/useScrollNearContainerEdges.stories.d.ts +7 -0
  85. package/dist/runtime/composables/useScrollNearContainerEdges.stories.js +85 -0
  86. package/dist/types.d.mts +6 -2
  87. package/dist/types.d.ts +7 -0
  88. package/package.json +11 -5
  89. package/src/module.ts +2 -1
  90. package/src/runtime/assets/utils.css +5 -5
  91. package/src/runtime/components/LibButton/LibButton.vue +2 -6
  92. package/src/runtime/nuxt/plugins/vue-plugin.ts +1 -1
  93. package/dist/runtime/components/Aria/Aria.vue.d.ts +0 -5
  94. package/dist/runtime/components/Icon/Icon.vue.d.ts +0 -21
  95. package/dist/runtime/components/LibButton/LibButton.vue.d.ts +0 -36
  96. package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +0 -42
  97. package/dist/runtime/components/LibColorInput/LibColorInput.vue.d.ts +0 -63
  98. package/dist/runtime/components/LibColorPicker/LibColorPicker.vue.d.ts +0 -61
  99. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue.d.ts +0 -22
  100. package/dist/runtime/components/LibDatePicker/LibDatePicker.vue.d.ts +0 -40
  101. package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue.d.ts +0 -34
  102. package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue.d.ts +0 -34
  103. package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue.d.ts +0 -22
  104. package/dist/runtime/components/LibDebug/LibDebug.vue.d.ts +0 -32
  105. package/dist/runtime/components/LibDevOnly/LibDevOnly.vue.d.ts +0 -22
  106. package/dist/runtime/components/LibFileInput/LibFileInput.vue.d.ts +0 -43
  107. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue.d.ts +0 -165
  108. package/dist/runtime/components/LibLabel/LibLabel.vue.d.ts +0 -27
  109. package/dist/runtime/components/LibMultiValues/LibMultiValues.vue.d.ts +0 -29
  110. package/dist/runtime/components/LibNotifications/LibNotification.vue.d.ts +0 -17
  111. package/dist/runtime/components/LibNotifications/LibNotifications.vue.d.ts +0 -13
  112. package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +0 -104
  113. package/dist/runtime/components/LibPalette/LibPalette.vue.d.ts +0 -14
  114. package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +0 -46
  115. package/dist/runtime/components/LibProgressBar/LibProgressBar.vue.d.ts +0 -41
  116. package/dist/runtime/components/LibRecorder/LibRecorder.vue.d.ts +0 -77
  117. package/dist/runtime/components/LibRoot/LibRoot.vue.d.ts +0 -41
  118. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue.d.ts +0 -35
  119. package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +0 -94
  120. package/dist/runtime/components/LibTable/LibTable.vue.d.ts +0 -45
  121. package/dist/runtime/components/Template/NAME.vue.d.ts +0 -17
  122. package/dist/runtime/components/TestControls/TestControls.vue.d.ts +0 -5
@@ -0,0 +1,10 @@
1
+ import type { Meta, StoryObj } from "@storybook/vue3";
2
+ import LibProgressBar from "./LibProgressBar.vue.js";
3
+ declare const meta: Meta<typeof LibProgressBar>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof LibProgressBar>;
6
+ export declare const Primary: Story;
7
+ export declare const Secondary: Story;
8
+ export declare const ReallyLongLabel: Story;
9
+ export declare const Static: Story;
10
+ export declare const AutoHiding: Story;
@@ -0,0 +1,81 @@
1
+ import { onUnmounted, ref } from "vue";
2
+ import LibProgressBar from "./LibProgressBar.vue";
3
+ import * as components from "../index.js";
4
+ const meta = {
5
+ component: LibProgressBar,
6
+ title: "Components/ProgressBar",
7
+ args: {
8
+ label: "Label",
9
+ // @ts-expect-error .
10
+ _timeout: 1e3,
11
+ _add: 10,
12
+ _start: 50
13
+ }
14
+ };
15
+ export default meta;
16
+ export const Primary = {
17
+ render: (args) => ({
18
+ components,
19
+ setup: () => {
20
+ const progress = ref(args._start);
21
+ if (args.progress) {
22
+ progress.value = args.progress;
23
+ } else {
24
+ const interval = setInterval(() => {
25
+ if (progress.value >= 100) {
26
+ progress.value = 0;
27
+ } else {
28
+ progress.value += args._add;
29
+ }
30
+ }, args._timeout);
31
+ onUnmounted(() => {
32
+ clearInterval(interval);
33
+ });
34
+ }
35
+ return {
36
+ args: { ...args },
37
+ progress
38
+ };
39
+ },
40
+ template: `
41
+ <lib-progress-bar class="flex-1" v-bind="args" :progress="progress"></lib-progress-bar>
42
+ <br/>
43
+ Stretched in flexbox:
44
+ <div class="flex w-full">
45
+ <lib-progress-bar class="flex-1" v-bind="args" :progress="progress"></lib-progress-bar>
46
+ </div>
47
+ `
48
+ })
49
+ };
50
+ export const Secondary = {
51
+ ...Primary,
52
+ args: {
53
+ ...Primary.args
54
+ }
55
+ };
56
+ export const ReallyLongLabel = {
57
+ ...Primary,
58
+ args: {
59
+ ...Primary.args,
60
+ 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"
61
+ }
62
+ };
63
+ export const Static = {
64
+ ...Primary,
65
+ args: {
66
+ ...Primary.args,
67
+ progress: 50
68
+ }
69
+ };
70
+ export const AutoHiding = {
71
+ ...Primary,
72
+ args: {
73
+ ...Primary.args,
74
+ autohideOnComplete: 500,
75
+ clamp: [10, 100],
76
+ _start: 0,
77
+ // keepSpaceWhenHidden: true,
78
+ _timeout: 1e3,
79
+ _add: 10
80
+ }
81
+ };
@@ -35,17 +35,17 @@
35
35
  before:transition-all
36
36
  before:z-1
37
37
  before:duration-500
38
- `, psuedoHide && `
38
+ `,psuedoHide && `
39
39
  after:opacity-0
40
40
  before:opacity-0
41
- `, $attrs.class)"
41
+ `, ($attrs as any).class)"
42
42
  :data-value="progress"
43
43
  :title="label"
44
44
  role="progressbar"
45
45
  :aria-valuenow="clampVal(progress, clamp[0] ?? 0, clamp[1] ?? 100)"
46
46
  :aria-valuemin="clamp[0] ?? 0"
47
47
  :aria-valuemax="clamp[1] ?? 100"
48
- v-bind="{ ...$attrs, class: void 0 }"
48
+ v-bind="{...$attrs, class:undefined}"
49
49
  :style="`--progress: ${clampVal(progress, clamp[0] ?? 0, clamp[1] ?? 100)}%;`"
50
50
  >
51
51
  <div class="procgress-bar--label-wrapper relative flex-1">
@@ -93,80 +93,101 @@
93
93
  </div>
94
94
  </Transition>
95
95
  </template>
96
+ <script setup lang="ts">
97
+ import { type HTMLAttributes,type PropType, ref, watch } from "vue"
98
+
99
+ import { twMerge } from "../../utils/twMerge.js"
100
+ import { type BaseInteractiveProps, baseInteractivePropsDefaults,getFallbackId,type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js"
101
+
102
+ // TODO move to utils
103
+ const clampVal = (n: number, min: number, max: number) => Math.min(Math.max(n, min), max)
96
104
 
97
- <script setup>
98
- import { ref, watch } from "vue";
99
- import { twMerge } from "../../utils/twMerge.js";
100
- import { baseInteractivePropsDefaults, getFallbackId } from "../shared/props.js";
101
- const clampVal = (n, min, max) => Math.min(Math.max(n, min), max);
102
105
  defineOptions({
103
- name: "lib-progress-bar",
104
- inheritAttrs: false
105
- });
106
- const fallbackId = getFallbackId();
107
- const props = defineProps(/* @__PURE__ */ _mergeDefaults({
108
- id: { type: String, required: false },
109
- disabled: { type: Boolean, required: false },
110
- readonly: { type: Boolean, required: false },
111
- border: { type: Boolean, required: false },
112
- unstyle: { type: Boolean, required: false },
113
- label: { type: String, required: false },
114
- progress: { type: Number, required: true },
115
- autohideOnComplete: { type: Number, required: false },
116
- keepSpaceWhenHidden: { type: Boolean, required: false },
117
- clamp: { type: Array, required: false }
118
- }, {
119
- autohideOnComplete: -1,
120
- keepSpaceWhenHidden: false,
121
- clamp: () => [0, 100],
122
- ...baseInteractivePropsDefaults
123
- }));
124
- const hide = ref(false);
125
- const psuedoHide = ref(false);
126
- let timeout;
127
- let type;
106
+ name: "lib-progress-bar",
107
+ inheritAttrs: false,
108
+ })
109
+ const fallbackId = getFallbackId()
110
+ const props = withDefaults(defineProps<Props>(), {
111
+ autohideOnComplete: -1,
112
+ keepSpaceWhenHidden: false,
113
+ clamp: () => [0, 100],
114
+ ...baseInteractivePropsDefaults
115
+ })
116
+ const hide = ref<boolean>(false)
117
+ const psuedoHide = ref<boolean>(false)
118
+ let timeout: number
119
+ let type: number
128
120
  if (props.autohideOnComplete > -1 && (props.progress >= 100 || props.progress < 0)) {
129
- if (props.keepSpaceWhenHidden) {
130
- hide.value = false;
131
- psuedoHide.value = true;
132
- } else {
133
- hide.value = true;
134
- psuedoHide.value = false;
135
- }
121
+ if (props.keepSpaceWhenHidden) {
122
+ hide.value = false
123
+ psuedoHide.value = true
124
+ } else {
125
+ hide.value = true
126
+ psuedoHide.value = false
127
+ }
136
128
  }
129
+
137
130
  watch([
138
- () => props.progress,
139
- () => props.keepSpaceWhenHidden,
140
- () => props.autohideOnComplete
131
+ () => props.progress,
132
+ () => props.keepSpaceWhenHidden,
133
+ () => props.autohideOnComplete,
141
134
  ], () => {
142
- if (props.autohideOnComplete > -1 && (props.progress >= 100 || props.progress < 0)) {
143
- if (props.keepSpaceWhenHidden) {
144
- if (type === 1) return;
145
- clearTimeout(timeout);
146
- type = 1;
147
- timeout = setTimeout(() => {
148
- type = 0;
149
- hide.value = false;
150
- psuedoHide.value = true;
151
- }, props.autohideOnComplete);
152
- } else {
153
- if (type === 2) return;
154
- clearTimeout(timeout);
155
- type = 2;
156
- timeout = setTimeout(() => {
157
- type = 0;
158
- hide.value = true;
159
- psuedoHide.value = false;
160
- }, props.autohideOnComplete);
161
- }
162
- } else {
163
- clearTimeout(timeout);
164
- hide.value = false;
165
- psuedoHide.value = false;
166
- }
167
- }, { immediate: false });
135
+ if (props.autohideOnComplete > -1 && (props.progress >= 100 || props.progress < 0)) {
136
+ if (props.keepSpaceWhenHidden) {
137
+ if (type === 1) return
138
+ clearTimeout(timeout)
139
+ type = 1
140
+ timeout = setTimeout(() => {
141
+ type = 0
142
+ hide.value = false
143
+ psuedoHide.value = true
144
+ }, props.autohideOnComplete) as any
145
+ } else {
146
+ if (type === 2) return
147
+ clearTimeout(timeout)
148
+ type = 2
149
+ timeout = setTimeout(() => {
150
+ type = 0
151
+ hide.value = true
152
+ psuedoHide.value = false
153
+ }, props.autohideOnComplete) as any
154
+ }
155
+ } else {
156
+ clearTimeout(timeout)
157
+ hide.value = false
158
+ psuedoHide.value = false
159
+ }
160
+ }, { immediate: false })
161
+
168
162
  </script>
163
+ <script lang="ts">
164
+
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
185
 
170
- <script>
186
+ interface Props
187
+ extends
188
+ /** @vue-ignore */
189
+ Partial<Omit<HTMLAttributes,"class"> & TailwindClassProp>,
190
+ RealProps
191
+ { }
171
192
 
172
193
  </script>
@@ -0,0 +1,19 @@
1
+ import type { Meta, StoryObj } from "@storybook/vue3";
2
+ import * as components from "../index.js.js";
3
+ /**
4
+ * This is a special input component designed to record any type of event.
5
+ *
6
+ * It requires additional setup to actually work since what and how anything is recorded is up to the needs of the application.
7
+ *
8
+ * This basic implementation just lists the keys. Enter accepts the recording, escape cancels back to the initial value.
9
+ */
10
+ declare const meta: Meta<typeof components.LibRecorder>;
11
+ export default meta;
12
+ type Story = StoryObj<typeof components.LibRecorder>;
13
+ export declare const Primary: Story;
14
+ /** Should not be tabbable or recordable. */
15
+ export declare const Disabled: Story;
16
+ /** *Should* be tabbable but not recordable. */
17
+ export declare const Readonly: Story;
18
+ /** Height should not shrink. */
19
+ export declare const EmptyInitialValue: Story;
@@ -0,0 +1,63 @@
1
+ import { ref, watchEffect } from "vue";
2
+ import { createRecorderHandler, createRecorderWatchEffect } from "../../helpers/storybook.js";
3
+ import * as components from "../index.js";
4
+ const meta = {
5
+ component: components.LibRecorder,
6
+ title: "Components/Recorder",
7
+ args: {
8
+ label: "Some Label",
9
+ recordingTitle: "Recording. Press enter or click away to accept. Press escape to cancel.",
10
+ modelValue: "K E Y S"
11
+ }
12
+ };
13
+ export default meta;
14
+ export const Primary = {
15
+ render: (args) => ({
16
+ components,
17
+ setup: () => {
18
+ const recording = ref(false);
19
+ const recordingValue = ref("");
20
+ const modelValue = ref(args.modelValue);
21
+ const recorderEl = ref(null);
22
+ const recorder = createRecorderHandler(recordingValue, recording, modelValue, recorderEl);
23
+ watchEffect(createRecorderWatchEffect(recordingValue, recording, modelValue));
24
+ return {
25
+ args,
26
+ modelValue,
27
+ recorder,
28
+ recording,
29
+ recordingValue,
30
+ recorderEl
31
+ };
32
+ },
33
+ template: `
34
+ <lib-recorder
35
+ v-bind="args"
36
+ v-extract-root-el="_ => recorderEl = _"
37
+ :recordingValue="recordingValue"
38
+ :recorder="recorder"
39
+ v-model:recording="recording"
40
+ v-model="modelValue"
41
+ @recorder:click="recording = !recording"
42
+ />
43
+ `
44
+ })
45
+ };
46
+ export const Disabled = {
47
+ ...Primary,
48
+ args: {
49
+ disabled: true
50
+ }
51
+ };
52
+ export const Readonly = {
53
+ ...Primary,
54
+ args: {
55
+ readonly: true
56
+ }
57
+ };
58
+ export const EmptyInitialValue = {
59
+ ...Primary,
60
+ args: {
61
+ modelValue: ""
62
+ }
63
+ };