vueless 0.0.291 → 0.0.292

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.291",
3
+ "version": "0.0.292",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -38,6 +38,9 @@ export default /*tw*/ {
38
38
  md: "text-sm placeholder:text-sm",
39
39
  lg: "text-base placeholder:text-base",
40
40
  },
41
+ resizable: {
42
+ false: "resize-none",
43
+ },
41
44
  },
42
45
  },
43
46
  defaults: {
@@ -46,6 +49,7 @@ export default /*tw*/ {
46
49
  type: "text",
47
50
  inputmode: "text",
48
51
  labelAlign: "topInside",
52
+ resizable: false,
49
53
  disabled: false,
50
54
  readonly: false,
51
55
  noAutocomplete: false,
@@ -29,7 +29,7 @@
29
29
  :placeholder="placeholder"
30
30
  :readonly="readonly"
31
31
  :disabled="disabled"
32
- :rows="rows"
32
+ :rows="currentRows"
33
33
  :inputmode="inputmode"
34
34
  :data-test="dataTest"
35
35
  v-bind="textareaAttrs"
@@ -39,6 +39,8 @@
39
39
  @mouseleave="onMouseleave"
40
40
  @mousedown="onMousedown"
41
41
  @click="onClick"
42
+ @keydown.enter="onEnter"
43
+ @keydown.backspace="onBackspace"
42
44
  />
43
45
  </label>
44
46
  <label v-if="hasSlotContent($slots['right'])" :for="id" v-bind="rightSlotAttrs">
@@ -49,7 +51,7 @@
49
51
  </template>
50
52
 
51
53
  <script setup>
52
- import { computed, onMounted, ref, useSlots } from "vue";
54
+ import { computed, onMounted, ref, watch, useSlots } from "vue";
53
55
 
54
56
  import ULabel from "../ui.form-label";
55
57
  import { getRandomId, getDefault } from "../service.ui";
@@ -112,6 +114,14 @@ const props = defineProps({
112
114
  default: "",
113
115
  },
114
116
 
117
+ /**
118
+ * Allow resizing of the textarea.
119
+ */
120
+ resizable: {
121
+ type: Boolean,
122
+ default: getDefault(defaultConfig, UTextarea).resizable,
123
+ },
124
+
115
125
  /**
116
126
  * Make textarea read only.
117
127
  */
@@ -157,7 +167,7 @@ const props = defineProps({
157
167
  * Set number of visible rows.
158
168
  */
159
169
  rows: {
160
- type: String,
170
+ type: [String, Number],
161
171
  default: getDefault(defaultConfig, UTextarea).rows,
162
172
  },
163
173
 
@@ -236,6 +246,33 @@ const labelComponentRef = ref(null);
236
246
  const leftSlotWrapperRef = ref(null);
237
247
  const textareaWrapperRef = ref(null);
238
248
 
249
+ const currentRows = ref(props.rows);
250
+
251
+ watch(
252
+ () => props.rows,
253
+ (newRows) => {
254
+ currentRows.value = newRows;
255
+ },
256
+ );
257
+
258
+ function onEnter() {
259
+ currentRows.value++;
260
+ }
261
+
262
+ function onBackspace() {
263
+ const textarea = textareaRef.value;
264
+
265
+ if (!textarea) return;
266
+
267
+ const content = textarea.value;
268
+ const newlineCount = (content.match(/\n/g) || []).length;
269
+ const newRowCount = Math.max(props.rows, newlineCount + 1);
270
+
271
+ if (newRowCount < currentRows.value) {
272
+ currentRows.value = newRowCount;
273
+ }
274
+ }
275
+
239
276
  const localValue = computed({
240
277
  get() {
241
278
  return props.modelValue;
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.291",
4
+ "version": "0.0.292",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
@@ -8067,6 +8067,15 @@
8067
8067
  },
8068
8068
  "default": "\"\""
8069
8069
  },
8070
+ {
8071
+ "name": "resizable",
8072
+ "description": "Allow resizing of the textarea.",
8073
+ "value": {
8074
+ "kind": "expression",
8075
+ "type": "boolean"
8076
+ },
8077
+ "default": "false"
8078
+ },
8070
8079
  {
8071
8080
  "name": "readonly",
8072
8081
  "description": "Make textarea read only.",
@@ -8117,7 +8126,7 @@
8117
8126
  "description": "Set number of visible rows.",
8118
8127
  "value": {
8119
8128
  "kind": "expression",
8120
- "type": "string"
8129
+ "type": "string|number"
8121
8130
  },
8122
8131
  "default": "3"
8123
8132
  },