vueless 0.0.239 → 0.0.240

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.240",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -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
  `,
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.240",
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.",