vueless 0.0.239 → 0.0.241

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.
@@ -1,4 +1,4 @@
1
- import { ref, computed, toValue } from "vue";
1
+ import { computed, toValue } from "vue";
2
2
 
3
3
  export const POSITION = {
4
4
  left: "left",
@@ -8,20 +8,17 @@ export const POSITION = {
8
8
  auto: "auto",
9
9
  };
10
10
 
11
- export function useAdjustElementPosition(
12
- anchorElement,
13
- targetElement,
14
- position,
15
- preferredPosition,
16
- ) {
17
- const preferredOpenDirectionY = ref(preferredPosition?.y || POSITION.bottom);
18
- const preferredOpenDirectionX = ref(preferredPosition?.x || POSITION.left);
19
-
11
+ export function useAutoPosition(anchorElement, targetElement, position, preferredPosition) {
20
12
  const localAnchorElement = computed(() => toValue(anchorElement));
21
13
  const localTargetElement = computed(() => toValue(targetElement));
22
14
  const localPosition = computed(() => toValue(position));
23
15
  const localPreferredPosition = computed(() => toValue(preferredPosition));
24
16
 
17
+ const preferredOpenDirectionY = computed(() => {
18
+ return localPreferredPosition.value?.y || POSITION.bottomi;
19
+ });
20
+ const preferredOpenDirectionX = computed(() => localPreferredPosition.value?.x || POSITION.left);
21
+
25
22
  const isTop = computed(() => {
26
23
  if (localPosition.value.y !== POSITION.auto) {
27
24
  return localPosition.value.y === POSITION.top;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.239",
3
+ "version": "0.0.241",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -42,3 +42,14 @@ export function cloneDeep(entity, cache = new WeakMap()) {
42
42
  ...Object.keys(entity).map((prop) => ({ [prop]: cloneDeep(entity[prop], cache) })),
43
43
  );
44
44
  }
45
+
46
+ export function debounce(func, wait) {
47
+ let timeout;
48
+
49
+ return function (...args) {
50
+ const context = this;
51
+
52
+ clearTimeout(timeout);
53
+ timeout = setTimeout(() => func.apply(context, args), wait);
54
+ };
55
+ }
@@ -3,7 +3,7 @@ import { cva } from "../../service.ui";
3
3
  import { computed, watchEffect } from "vue";
4
4
 
5
5
  import defaultConfig from "../configs/default.config";
6
- import { POSITION } from "../../composable.adjustElementPosition";
6
+ import { POSITION } from "../../composable.autoPosition";
7
7
 
8
8
  export default function useAttrs(props, { isShownCalendar, isTop, isRight }) {
9
9
  const { config, getAttrs, isSystemKey } = useUI(defaultConfig, () => props.config);
@@ -111,6 +111,7 @@ export default /*tw*/ {
111
111
  size: "md",
112
112
  openDirectionX: "auto",
113
113
  openDirectionY: "auto",
114
+ labelAlign: "topInside",
114
115
  timepicker: false,
115
116
  disabled: false,
116
117
  dateFormat: undefined,
@@ -4,6 +4,7 @@
4
4
  :id="id"
5
5
  :key="isShownCalendar"
6
6
  v-model="userFormatDate"
7
+ :label-align="labelAlign"
7
8
  :label="label"
8
9
  :placeholder="placeholder"
9
10
  :error="error"
@@ -68,7 +69,7 @@ import { addDays, isSameDay } from "../ui.form-calendar/services/date.service";
68
69
 
69
70
  import useAttrs from "./composables/attrs.composable";
70
71
  import { useLocale } from "../composable.locale";
71
- import { useAdjustElementPosition } from "../composable.adjustElementPosition";
72
+ import { useAutoPosition } from "../composable.autoPosition";
72
73
 
73
74
  import defaultConfig from "./configs/default.config";
74
75
  import { UDatePicker } from "./constants";
@@ -85,6 +86,15 @@ const props = defineProps({
85
86
  default: "",
86
87
  },
87
88
 
89
+ /**
90
+ * Set label placement related from the default slot.
91
+ * @values top, topInside, topWithDesc, left, right
92
+ */
93
+ labelAlign: {
94
+ type: String,
95
+ default: UIService.get(defaultConfig, UDatePicker).default.labelAlign,
96
+ },
97
+
88
98
  /**
89
99
  * Datepicker placeholder.
90
100
  */
@@ -248,10 +258,10 @@ const calendarRef = ref(null);
248
258
 
249
259
  const calendarWrapperRef = computed(() => calendarRef?.value?.wrapperRef);
250
260
 
251
- const { isTop, isRight, adjustPositionY, adjustPositionX } = useAdjustElementPosition(
261
+ const { isTop, isRight, adjustPositionY, adjustPositionX } = useAutoPosition(
252
262
  wrapperRef,
253
263
  calendarWrapperRef,
254
- { x: props.openDirectionX, y: props.openDirectionY },
264
+ computed(() => ({ x: props.openDirectionX, y: props.openDirectionY })),
255
265
  { x: "left", y: "bottom" },
256
266
  );
257
267
 
@@ -4,7 +4,7 @@ import { cx, cva } from "../../service.ui";
4
4
  import { computed, watchEffect } from "vue";
5
5
 
6
6
  import defaultConfig from "../configs/default.config";
7
- import { POSITION } from "../../composable.adjustElementPosition";
7
+ import { POSITION } from "../../composable.autoPosition";
8
8
 
9
9
  export default function useAttrs(props, { isShownMenu, isTop, isRight }) {
10
10
  const { config, getAttrs, isSystemKey } = useUI(defaultConfig, () => props.config);
@@ -151,7 +151,7 @@ export const MinMax = DefaultTemplate.bind({});
151
151
  MinMax.args = {
152
152
  minDate: new Date(2022, 2, 22),
153
153
  maxDate: new Date(2022, 2, 26),
154
- value: { from: new Date(2022, 2, 24), to: null },
154
+ value: { from: new Date(2022, 2, 24), to: new Date(2022, 2, 25) },
155
155
  };
156
156
 
157
157
  export const DateFormat = DefaultTemplate.bind({});
@@ -259,7 +259,7 @@ import {
259
259
  import useAttrs from "./composables/attrs.composable";
260
260
  import { useLocale } from "../composable.locale";
261
261
  import useBreakpoint from "../composable.breakpoint";
262
- import { useAdjustElementPosition } from "../composable.adjustElementPosition";
262
+ import { useAutoPosition } from "../composable.autoPosition";
263
263
 
264
264
  import defaultConfig from "./configs/default.config";
265
265
  import {
@@ -443,17 +443,11 @@ const buttonPrevRef = ref(null);
443
443
  const buttonNextRef = ref(null);
444
444
  const inputRef = ref(null);
445
445
 
446
- const { isTop, isRight, adjustPositionY, adjustPositionX } = useAdjustElementPosition(
446
+ const { isTop, isRight, adjustPositionY, adjustPositionX } = useAutoPosition(
447
447
  wrapperRef,
448
448
  menuRef,
449
- {
450
- x: props.openDirectionX,
451
- y: props.openDirectionY,
452
- },
453
- {
454
- x: "left",
455
- y: "bottom",
456
- },
449
+ computed(() => ({ x: props.openDirectionX, y: props.openDirectionY })),
450
+ { x: "left", y: "bottom" },
457
451
  );
458
452
 
459
453
  const {
@@ -100,14 +100,12 @@ const LabelPlacementTemplate = (args) => ({
100
100
  <UCol gap="xl">
101
101
  <UInput
102
102
  v-bind="args"
103
- label="top"
104
- :label-outside="true"
103
+ label-align="top"
105
104
  />
106
105
 
107
106
  <UInput
108
107
  v-bind="args"
109
- label="topInside"
110
- :label-outside="false"
108
+ label-align="topInside"
111
109
  />
112
110
  </UCol>
113
111
  `,
@@ -15,6 +15,7 @@ export default /*tw*/ {
15
15
  defaultVariants: {
16
16
  size: "md",
17
17
  labelAlign: "topInside",
18
+ debounce: 300,
18
19
  disabled: false,
19
20
  searchButton: false,
20
21
  },
@@ -81,6 +81,7 @@ import UIcon from "../ui.image-icon";
81
81
  import UInput from "../ui.form-input";
82
82
  import UButton from "../ui.button";
83
83
  import UIService, { getRandomId } from "../service.ui";
84
+ import { debounce as debounceMethod } from "../service.helper";
84
85
 
85
86
  import { UInputSearch } from "./constants";
86
87
  import defaultConfig from "./configs/default.config";
@@ -173,6 +174,11 @@ const props = defineProps({
173
174
  default: () => getRandomId(),
174
175
  },
175
176
 
177
+ debounce: {
178
+ type: Number,
179
+ default: UIService.get(defaultConfig, UInputSearch).default.debounce,
180
+ },
181
+
176
182
  /**
177
183
  * Component ui config object.
178
184
  */
@@ -215,10 +221,10 @@ const { config, inputAttrs, searchIconAttrs, clearIconAttrs, buttonAttrs } = use
215
221
 
216
222
  const search = computed({
217
223
  get: () => props.modelValue,
218
- set: (value) => {
224
+ set: debounceMethod((value) => {
219
225
  localValue.value = value;
220
226
  emit("update:modelValue", value);
221
- },
227
+ }, props.debounce),
222
228
  });
223
229
 
224
230
  const iconSize = computed(() => {
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.239",
4
+ "version": "0.0.241",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
@@ -2059,6 +2059,15 @@
2059
2059
  },
2060
2060
  "default": "\"\""
2061
2061
  },
2062
+ {
2063
+ "name": "labelAlign",
2064
+ "description": "Set label placement related from the default slot.",
2065
+ "value": {
2066
+ "kind": "expression",
2067
+ "type": "'top' | 'topInside' | 'topWithDesc' | 'left' | 'right'"
2068
+ },
2069
+ "default": "topInside"
2070
+ },
2062
2071
  {
2063
2072
  "name": "placeholder",
2064
2073
  "description": "Datepicker placeholder.",
@@ -4973,6 +4982,14 @@
4973
4982
  },
4974
4983
  "default": "() => getRandomId()"
4975
4984
  },
4985
+ {
4986
+ "name": "debounce",
4987
+ "value": {
4988
+ "kind": "expression",
4989
+ "type": "number"
4990
+ },
4991
+ "default": "300"
4992
+ },
4976
4993
  {
4977
4994
  "name": "config",
4978
4995
  "description": "Component ui config object.",