windly-ui 1.0.8 → 1.1.0

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 (64) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/runtime/components/Alert.d.vue.ts +18 -0
  3. package/dist/runtime/components/Alert.vue +21 -3
  4. package/dist/runtime/components/Alert.vue.d.ts +18 -0
  5. package/dist/runtime/components/Avatar.d.vue.ts +5 -5
  6. package/dist/runtime/components/Avatar.vue.d.ts +5 -5
  7. package/dist/runtime/components/Badge.d.vue.ts +5 -5
  8. package/dist/runtime/components/Badge.vue.d.ts +5 -5
  9. package/dist/runtime/components/Breadcrumbs.vue +2 -2
  10. package/dist/runtime/components/Button.d.vue.ts +5 -5
  11. package/dist/runtime/components/Button.vue +5 -5
  12. package/dist/runtime/components/Button.vue.d.ts +5 -5
  13. package/dist/runtime/components/Card.d.vue.ts +27 -0
  14. package/dist/runtime/components/Card.vue +12 -8
  15. package/dist/runtime/components/Card.vue.d.ts +27 -0
  16. package/dist/runtime/components/Checkbox.d.vue.ts +14 -5
  17. package/dist/runtime/components/Checkbox.vue +11 -4
  18. package/dist/runtime/components/Checkbox.vue.d.ts +14 -5
  19. package/dist/runtime/components/Chip.d.vue.ts +5 -5
  20. package/dist/runtime/components/Chip.vue +1 -1
  21. package/dist/runtime/components/Chip.vue.d.ts +5 -5
  22. package/dist/runtime/components/CodeBlock.vue +50 -8
  23. package/dist/runtime/components/Date.d.vue.ts +22 -4
  24. package/dist/runtime/components/Date.vue +39 -15
  25. package/dist/runtime/components/Date.vue.d.ts +22 -4
  26. package/dist/runtime/components/Dialog.d.vue.ts +7 -9
  27. package/dist/runtime/components/Dialog.vue +23 -4
  28. package/dist/runtime/components/Dialog.vue.d.ts +7 -9
  29. package/dist/runtime/components/Divider.vue +1 -1
  30. package/dist/runtime/components/Dropdown.d.vue.ts +2 -2
  31. package/dist/runtime/components/Dropdown.vue +71 -23
  32. package/dist/runtime/components/Dropdown.vue.d.ts +2 -2
  33. package/dist/runtime/components/FileUploader.d.vue.ts +1 -1
  34. package/dist/runtime/components/FileUploader.vue +11 -9
  35. package/dist/runtime/components/FileUploader.vue.d.ts +1 -1
  36. package/dist/runtime/components/Image.d.vue.ts +11 -1
  37. package/dist/runtime/components/Image.vue +15 -0
  38. package/dist/runtime/components/Image.vue.d.ts +11 -1
  39. package/dist/runtime/components/Input.d.vue.ts +5 -1
  40. package/dist/runtime/components/Input.vue +53 -14
  41. package/dist/runtime/components/Input.vue.d.ts +5 -1
  42. package/dist/runtime/components/Radio.d.vue.ts +2 -2
  43. package/dist/runtime/components/Radio.vue +9 -7
  44. package/dist/runtime/components/Radio.vue.d.ts +2 -2
  45. package/dist/runtime/components/ScrollArea.vue +4 -0
  46. package/dist/runtime/components/Select.d.vue.ts +1 -1
  47. package/dist/runtime/components/Select.vue +11 -9
  48. package/dist/runtime/components/Select.vue.d.ts +1 -1
  49. package/dist/runtime/components/Tabs.d.vue.ts +8 -1
  50. package/dist/runtime/components/Tabs.vue +21 -6
  51. package/dist/runtime/components/Tabs.vue.d.ts +8 -1
  52. package/dist/runtime/components/Textarea.d.vue.ts +39 -185
  53. package/dist/runtime/components/Textarea.vue +94 -71
  54. package/dist/runtime/components/Textarea.vue.d.ts +39 -185
  55. package/dist/runtime/components/Toggle.d.vue.ts +9 -3
  56. package/dist/runtime/components/Toggle.vue +70 -122
  57. package/dist/runtime/components/Toggle.vue.d.ts +9 -3
  58. package/dist/runtime/components/Tooltip.vue +3 -0
  59. package/dist/runtime/components/uiProps.d.ts +2 -2
  60. package/dist/runtime/components/uiProps.js +2 -2
  61. package/dist/runtime/components/useUiClasses.d.ts +3 -1
  62. package/dist/runtime/components/useUiClasses.js +7 -5
  63. package/dist/runtime/docs/index.vue +163 -72
  64. package/package.json +1 -1
@@ -2,67 +2,37 @@
2
2
  defineOptions({
3
3
  inheritAttrs: false
4
4
  });
5
- import { computed, ref, watch, nextTick } from "vue";
5
+ import { computed, ref, watch, nextTick, onMounted, onBeforeUnmount } from "vue";
6
6
  import { useUiClasses } from "./useUiClasses";
7
- import { uiProps } from "./uiProps";
8
7
  const props = defineProps({
9
- modelValue: {
10
- type: String,
11
- default: ""
12
- },
13
- label: {
14
- type: String,
15
- default: ""
16
- },
17
- placeholder: {
18
- type: String,
19
- default: ""
20
- },
21
- rows: {
22
- type: Number,
23
- default: 3
24
- },
25
- maxRows: {
26
- type: Number,
27
- default: 10
28
- },
29
- autoGrow: {
30
- type: Boolean,
31
- default: false
32
- },
33
- readonly: {
34
- type: Boolean,
35
- default: false
36
- },
37
- error: {
38
- type: Boolean,
39
- default: false
40
- },
41
- errorMessage: {
42
- type: String,
43
- default: ""
44
- },
45
- hint: {
46
- type: String,
47
- default: ""
48
- },
49
- showWordCount: {
50
- type: Boolean,
51
- default: false
52
- },
53
- showCharCount: {
54
- type: Boolean,
55
- default: false
56
- },
57
- maxlength: {
58
- type: Number,
59
- default: void 0
60
- },
61
- ...uiProps
8
+ modelValue: { type: String, required: false, default: "" },
9
+ label: { type: String, required: false, default: "" },
10
+ placeholder: { type: String, required: false, default: "" },
11
+ rows: { type: Number, required: false, default: 3 },
12
+ maxRows: { type: Number, required: false, default: 10 },
13
+ autoGrow: { type: Boolean, required: false, default: false },
14
+ readonly: { type: Boolean, required: false, default: false },
15
+ error: { type: Boolean, required: false, default: false },
16
+ errorMessage: { type: String, required: false, default: "" },
17
+ hint: { type: String, required: false, default: "" },
18
+ showWordCount: { type: Boolean, required: false, default: false },
19
+ showCharCount: { type: Boolean, required: false, default: false },
20
+ maxlength: { type: Number, required: false, default: void 0 },
21
+ outlined: { type: Boolean, required: false, default: false },
22
+ borderless: { type: Boolean, required: false, default: false },
23
+ filled: { type: Boolean, required: false, default: false },
24
+ flat: { type: Boolean, required: false, default: false },
25
+ contentClass: { type: String, required: false, default: "" },
26
+ contentStyle: { type: String, required: false, default: "" },
27
+ textColor: { type: String, required: false, default: "" },
28
+ disabled: { type: Boolean, required: false, default: false },
29
+ loading: { type: Boolean, required: false, default: false },
30
+ color: { type: String, required: false, default: "indigo-400" },
31
+ rounded: { type: String, required: false, default: "md" },
32
+ size: { type: String, required: false, default: "md" },
33
+ iconSize: { type: String, required: false, default: "lg" }
62
34
  });
63
- const emit = defineEmits([
64
- "update:modelValue"
65
- ]);
35
+ const emit = defineEmits(["update:modelValue"]);
66
36
  const textareaRef = ref();
67
37
  const {
68
38
  contentClass,
@@ -71,7 +41,7 @@ const {
71
41
  textColor,
72
42
  rounded,
73
43
  size,
74
- disable,
44
+ disabled,
75
45
  roundedClass,
76
46
  sizeClass,
77
47
  computedContentClass,
@@ -88,6 +58,7 @@ const textareaStyle = computed(() => {
88
58
  };
89
59
  if (isHex(color.value)) {
90
60
  style.borderColor = color.value;
61
+ style["--tw-ring-color"] = color.value;
91
62
  }
92
63
  if (isHex(textColor.value)) {
93
64
  style.color = textColor.value;
@@ -103,22 +74,37 @@ const textareaClass = computed(() => {
103
74
  const pClass = paddingClass[pKey] ?? "";
104
75
  let cls = `
105
76
  w-full
106
- border
107
77
  transition-all
108
78
  duration-300
109
79
  focus:outline-none
110
- focus:ring-2
111
80
  ${rClass}
112
81
  ${sClass}
113
82
  ${pClass}
114
83
  `;
115
- if (disable.value) {
84
+ if (props.borderless) {
85
+ cls += " border-none bg-transparent";
86
+ } else if (props.outlined) {
87
+ cls += " border";
88
+ } else if (props.filled) {
89
+ cls += " border-0 border-b bg-gray-100 dark:bg-gray-800";
90
+ } else {
91
+ cls += " border-0 border-b";
92
+ }
93
+ if (!props.flat) {
94
+ cls += " shadow-sm";
95
+ }
96
+ if (disabled.value) {
116
97
  cls += " opacity-50 cursor-not-allowed";
117
98
  }
99
+ if (props.autoGrow) {
100
+ cls += " resize-none overflow-hidden";
101
+ }
118
102
  if (props.error) {
119
- cls += " border-red-500";
103
+ cls += " border-red-500 focus:ring-0 focus:ring-red-500";
120
104
  } else if (!isHex(color.value)) {
121
- cls += ` border-${color.value}`;
105
+ cls += ` border-${color.value} focus:ring-0 focus:ring-${color.value}`;
106
+ } else {
107
+ cls += " focus:ring-0";
122
108
  }
123
109
  if (textColor.value && !isHex(textColor.value)) {
124
110
  cls += ` text-${textColor.value}`;
@@ -140,19 +126,52 @@ function updateValue(event) {
140
126
  );
141
127
  }
142
128
  function resizeTextarea() {
143
- if (!props.autoGrow) return;
144
- if (!textareaRef.value) return;
145
- textareaRef.value.style.height = "auto";
146
- textareaRef.value.style.height = textareaRef.value.scrollHeight + "px";
129
+ const el = textareaRef.value;
130
+ if (!el) return;
131
+ if (!props.autoGrow) {
132
+ el.style.height = "";
133
+ el.style.overflowY = "";
134
+ return;
135
+ }
136
+ el.style.height = "auto";
137
+ const styles = window.getComputedStyle(el);
138
+ const lineHeight = parseFloat(styles.lineHeight) || parseFloat(styles.fontSize) * 1.2 || 20;
139
+ const paddingTop = parseFloat(styles.paddingTop) || 0;
140
+ const paddingBottom = parseFloat(styles.paddingBottom) || 0;
141
+ const borderTop = parseFloat(styles.borderTopWidth) || 0;
142
+ const borderBottom = parseFloat(styles.borderBottomWidth) || 0;
143
+ const verticalExtra = paddingTop + paddingBottom + borderTop + borderBottom;
144
+ const maxHeight = lineHeight * props.maxRows + verticalExtra;
145
+ const minHeight = lineHeight * props.rows + verticalExtra;
146
+ const targetHeight = Math.min(Math.max(el.scrollHeight, minHeight), maxHeight);
147
+ el.style.height = `${targetHeight}px`;
148
+ el.style.overflowY = el.scrollHeight > maxHeight ? "auto" : "hidden";
147
149
  }
148
150
  watch(
149
151
  () => props.modelValue,
150
152
  async () => {
151
153
  await nextTick();
152
154
  resizeTextarea();
153
- },
154
- { immediate: true }
155
+ }
155
156
  );
157
+ watch(
158
+ () => props.autoGrow,
159
+ async () => {
160
+ await nextTick();
161
+ resizeTextarea();
162
+ }
163
+ );
164
+ function handleWindowResize() {
165
+ resizeTextarea();
166
+ }
167
+ onMounted(async () => {
168
+ await nextTick();
169
+ resizeTextarea();
170
+ window.addEventListener("resize", handleWindowResize);
171
+ });
172
+ onBeforeUnmount(() => {
173
+ window.removeEventListener("resize", handleWindowResize);
174
+ });
156
175
  </script>
157
176
 
158
177
  <template>
@@ -161,7 +180,7 @@ watch(
161
180
  {{ label }}
162
181
  </label>
163
182
 
164
- <textarea ref="textareaRef" :value="modelValue" :rows="rows" :placeholder="placeholder" :disabled="disable"
183
+ <textarea ref="textareaRef" :value="modelValue" :rows="rows" :placeholder="placeholder" :disabled="disabled"
165
184
  :readonly="readonly" :maxlength="maxlength" :class="textareaClass" :style="textareaStyle"
166
185
  @input="updateValue" v-bind="$attrs" />
167
186
  <div class="flex justify-between text-xs text-gray-500">
@@ -183,3 +202,7 @@ watch(
183
202
  </div>
184
203
  </div>
185
204
  </template>
205
+
206
+ <style scoped>
207
+ textarea{-moz-appearance:none;appearance:none;-webkit-appearance:none}textarea:focus{outline:none}
208
+ </style>
@@ -1,201 +1,55 @@
1
- declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
- contentClass: {
3
- readonly type: StringConstructor;
4
- readonly default: "";
5
- };
6
- contentStyle: {
7
- readonly type: StringConstructor;
8
- readonly default: "";
9
- };
10
- textColor: {
11
- readonly type: StringConstructor;
12
- readonly default: "";
13
- };
14
- disable: {
15
- readonly type: BooleanConstructor;
16
- readonly default: false;
17
- };
18
- loading: {
19
- readonly type: BooleanConstructor;
20
- readonly default: false;
21
- };
22
- color: {
23
- readonly type: StringConstructor;
24
- readonly default: "blue-900";
25
- };
26
- rounded: {
27
- readonly type: StringConstructor;
28
- readonly default: "md";
29
- };
30
- size: {
31
- readonly type: StringConstructor;
32
- readonly default: "md";
33
- };
34
- iconSize: {
35
- readonly type: StringConstructor;
36
- readonly default: "lg";
37
- };
38
- modelValue: {
39
- type: StringConstructor;
40
- default: string;
41
- };
42
- label: {
43
- type: StringConstructor;
44
- default: string;
45
- };
46
- placeholder: {
47
- type: StringConstructor;
48
- default: string;
49
- };
50
- rows: {
51
- type: NumberConstructor;
52
- default: number;
53
- };
54
- maxRows: {
55
- type: NumberConstructor;
56
- default: number;
57
- };
58
- autoGrow: {
59
- type: BooleanConstructor;
60
- default: boolean;
61
- };
62
- readonly: {
63
- type: BooleanConstructor;
64
- default: boolean;
65
- };
66
- error: {
67
- type: BooleanConstructor;
68
- default: boolean;
69
- };
70
- errorMessage: {
71
- type: StringConstructor;
72
- default: string;
73
- };
74
- hint: {
75
- type: StringConstructor;
76
- default: string;
77
- };
78
- showWordCount: {
79
- type: BooleanConstructor;
80
- default: boolean;
81
- };
82
- showCharCount: {
83
- type: BooleanConstructor;
84
- default: boolean;
85
- };
86
- maxlength: {
87
- type: NumberConstructor;
88
- default: undefined;
89
- };
90
- }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
91
- "update:modelValue": (...args: any[]) => void;
92
- }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
93
- contentClass: {
94
- readonly type: StringConstructor;
95
- readonly default: "";
96
- };
97
- contentStyle: {
98
- readonly type: StringConstructor;
99
- readonly default: "";
100
- };
101
- textColor: {
102
- readonly type: StringConstructor;
103
- readonly default: "";
104
- };
105
- disable: {
106
- readonly type: BooleanConstructor;
107
- readonly default: false;
108
- };
109
- loading: {
110
- readonly type: BooleanConstructor;
111
- readonly default: false;
112
- };
113
- color: {
114
- readonly type: StringConstructor;
115
- readonly default: "blue-900";
116
- };
117
- rounded: {
118
- readonly type: StringConstructor;
119
- readonly default: "md";
120
- };
121
- size: {
122
- readonly type: StringConstructor;
123
- readonly default: "md";
124
- };
125
- iconSize: {
126
- readonly type: StringConstructor;
127
- readonly default: "lg";
128
- };
129
- modelValue: {
130
- type: StringConstructor;
131
- default: string;
132
- };
133
- label: {
134
- type: StringConstructor;
135
- default: string;
136
- };
137
- placeholder: {
138
- type: StringConstructor;
139
- default: string;
140
- };
141
- rows: {
142
- type: NumberConstructor;
143
- default: number;
144
- };
145
- maxRows: {
146
- type: NumberConstructor;
147
- default: number;
148
- };
149
- autoGrow: {
150
- type: BooleanConstructor;
151
- default: boolean;
152
- };
153
- readonly: {
154
- type: BooleanConstructor;
155
- default: boolean;
156
- };
157
- error: {
158
- type: BooleanConstructor;
159
- default: boolean;
160
- };
161
- errorMessage: {
162
- type: StringConstructor;
163
- default: string;
164
- };
165
- hint: {
166
- type: StringConstructor;
167
- default: string;
168
- };
169
- showWordCount: {
170
- type: BooleanConstructor;
171
- default: boolean;
172
- };
173
- showCharCount: {
174
- type: BooleanConstructor;
175
- default: boolean;
176
- };
177
- maxlength: {
178
- type: NumberConstructor;
179
- default: undefined;
180
- };
181
- }>> & Readonly<{
182
- "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
1
+ type __VLS_Props = {
2
+ modelValue?: string;
3
+ label?: string;
4
+ placeholder?: string;
5
+ rows?: number;
6
+ maxRows?: number;
7
+ autoGrow?: boolean;
8
+ readonly?: boolean;
9
+ error?: boolean;
10
+ errorMessage?: string;
11
+ hint?: string;
12
+ showWordCount?: boolean;
13
+ showCharCount?: boolean;
14
+ maxlength?: number;
15
+ outlined?: boolean;
16
+ borderless?: boolean;
17
+ filled?: boolean;
18
+ flat?: boolean;
19
+ contentClass?: string;
20
+ contentStyle?: string;
21
+ textColor?: string;
22
+ disabled?: boolean;
23
+ loading?: boolean;
24
+ color?: string;
25
+ rounded?: string;
26
+ size?: string;
27
+ iconSize?: string;
28
+ };
29
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
30
+ "update:modelValue": (value: string) => any;
31
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
32
+ "onUpdate:modelValue"?: ((value: string) => any) | undefined;
183
33
  }>, {
184
34
  modelValue: string;
35
+ disabled: boolean;
185
36
  label: string;
186
37
  color: string;
187
38
  size: string;
39
+ filled: boolean;
40
+ flat: boolean;
188
41
  contentClass: string;
189
42
  contentStyle: string;
190
43
  textColor: string;
191
- disable: boolean;
192
44
  loading: boolean;
193
45
  rounded: string;
194
46
  iconSize: string;
195
47
  placeholder: string;
48
+ hint: string;
196
49
  readonly: boolean;
197
50
  error: boolean;
198
- hint: string;
51
+ outlined: boolean;
52
+ borderless: boolean;
199
53
  errorMessage: string;
200
54
  maxlength: number;
201
55
  rows: number;
@@ -203,6 +57,6 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
203
57
  autoGrow: boolean;
204
58
  showWordCount: boolean;
205
59
  showCharCount: boolean;
206
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
60
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
207
61
  declare const _default: typeof __VLS_export;
208
62
  export default _default;
@@ -1,8 +1,9 @@
1
1
  type LabelPosition = 'top' | 'bottom' | 'left' | 'right';
2
- type ToggleSize = 'small' | 'medium' | 'large';
2
+ type ToggleSize = 'sm' | 'md' | 'lg';
3
3
  type __VLS_Props = {
4
4
  modelValue?: boolean | string | number;
5
5
  label?: string;
6
+ hint?: string;
6
7
  labelPosition?: LabelPosition;
7
8
  customClasses?: string;
8
9
  trueColor?: string;
@@ -12,7 +13,9 @@ type __VLS_Props = {
12
13
  inactiveValue?: string | number | boolean;
13
14
  activeIcon?: string;
14
15
  inactiveIcon?: string;
15
- disable?: boolean;
16
+ disabled?: boolean;
17
+ error?: boolean;
18
+ errorMessage?: string;
16
19
  };
17
20
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
18
21
  "update:modelValue": (value: string | number | boolean) => any;
@@ -20,9 +23,12 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
20
23
  "onUpdate:modelValue"?: ((value: string | number | boolean) => any) | undefined;
21
24
  }>, {
22
25
  modelValue: boolean | string | number;
26
+ disabled: boolean;
23
27
  label: string;
24
28
  size: ToggleSize;
25
- disable: boolean;
29
+ hint: string;
30
+ error: boolean;
31
+ errorMessage: string;
26
32
  labelPosition: LabelPosition;
27
33
  customClasses: string;
28
34
  trueColor: string;