v-uixy 1.9.0 → 1.9.1

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": "v-uixy",
3
- "version": "1.9.0",
3
+ "version": "1.9.1",
4
4
  "private": false,
5
5
  "author": {
6
6
  "name": "Alan Haber",
@@ -29,7 +29,7 @@
29
29
  :transition="{ ease: 'easeInOut', duration: 0.15 }"
30
30
  >
31
31
  <uixy-icon
32
- v-if="props.icon && !props.loading"
32
+ v-if="props.icon"
33
33
  :name="props.icon"
34
34
  :class="iconStyles({ position: props.iconPosition ?? 'left' })"
35
35
  />
@@ -67,7 +67,7 @@
67
67
  :transition="{ ease: 'easeInOut', duration: 0.15 }"
68
68
  >
69
69
  <uixy-icon
70
- v-if="props.icon && !props.loading"
70
+ v-if="props.icon"
71
71
  :name="props.icon"
72
72
  :class="iconStyles({ position: props.iconPosition ?? 'left' })"
73
73
  />
@@ -1,10 +1,25 @@
1
1
  <template>
2
- <div class="flex w-full flex-col gap-1">
3
- <label v-if="props.label" :class="labelStyles({ status })">
2
+ <div :class="['flex flex-col gap-1', $slots.trigger ? 'w-fit' : 'w-full']">
3
+ <label v-if="props.label && !$slots.trigger" :class="labelStyles({ status })">
4
4
  {{ props.label }}
5
5
  </label>
6
6
 
7
7
  <div
8
+ v-if="$slots.trigger"
9
+ ref="triggerRef"
10
+ class="inline-flex w-fit"
11
+ role="button"
12
+ :tabindex="props.disabled ? -1 : 0"
13
+ :aria-expanded="active"
14
+ @click="onTriggerClick"
15
+ @keydown.enter.prevent="onTriggerClick"
16
+ @keydown.space.prevent="onTriggerClick"
17
+ >
18
+ <slot name="trigger" :open="active" :value="model" />
19
+ </div>
20
+
21
+ <div
22
+ v-else
8
23
  ref="triggerRef"
9
24
  role="button"
10
25
  :tabindex="props.disabled ? -1 : 0"
@@ -150,7 +165,12 @@
150
165
 
151
166
  const triggerRef = ref<HTMLElement>();
152
167
 
153
- const draftTime = ref<UixyTimeParts>(timePartsOf(model.value));
168
+ const seedTime = (): UixyTimeParts =>
169
+ model.value
170
+ ? timePartsOf(model.value)
171
+ : { hour: props.defaultHour ?? 0, minute: 0, second: 0 };
172
+
173
+ const draftTime = ref<UixyTimeParts>(seedTime());
154
174
 
155
175
  const status = computed(() => {
156
176
  if (props.disabled) return "disabled";
@@ -209,11 +229,11 @@
209
229
  const clear = () => {
210
230
  model.value = null;
211
231
 
212
- draftTime.value = { hour: 0, minute: 0, second: 0 };
232
+ draftTime.value = { hour: props.defaultHour ?? 0, minute: 0, second: 0 };
213
233
  };
214
234
 
215
235
  watch(active, (isActive) => {
216
- if (isActive) draftTime.value = timePartsOf(model.value);
236
+ if (isActive) draftTime.value = seedTime();
217
237
  });
218
238
 
219
239
  const onDocClick = (event: MouseEvent) => {
@@ -11,6 +11,7 @@ export interface UixyDatePickerProps {
11
11
  icon?: IconName;
12
12
  withTime?: boolean;
13
13
  withSeconds?: boolean;
14
+ defaultHour?: number;
14
15
  startOfWeek?: "Sunday" | "Monday";
15
16
  isDateDisabled?: (date: Date) => boolean;
16
17
  direction?: "top" | "bottom";
@@ -18,14 +18,16 @@ export const inputStyles = styles(
18
18
  xl: "px-3.5 py-2.5 text-base",
19
19
  },
20
20
  icon: {
21
- left: "pl-8",
22
- right: "pr-8",
21
+ left: "",
22
+ right: "",
23
23
  none: "",
24
24
  },
25
25
  },
26
26
  {
27
27
  "size.sm+icon.left": "pl-7",
28
28
  "size.sm+icon.right": "pr-7",
29
+ "size.md+icon.left": "pl-9",
30
+ "size.md+icon.right": "pr-9",
29
31
  "size.xl+icon.left": "pl-9",
30
32
  "size.xl+icon.right": "pr-9",
31
33
  },
@@ -12,6 +12,7 @@
12
12
  :class="modalStyles($attrs.class as string)"
13
13
  :style="{ zIndex }"
14
14
  :[modalAttr]="''"
15
+ :data-uixy-modal-id="id"
15
16
  data-uixy-overlay
16
17
  @click.self="handleClick"
17
18
  >
@@ -48,6 +49,7 @@
48
49
  const rootRef = ref<HTMLElement>();
49
50
 
50
51
  const {
52
+ id,
51
53
  zIndex,
52
54
  isTopModal,
53
55
  open: openLayer,
@@ -47,6 +47,7 @@ export function useOverlayLayer(): UseOverlayLayerReturn {
47
47
  const MANAGED_ATTR = "data-uixy-inert-managed";
48
48
  const OVERLAY_ATTR = "data-uixy-overlay";
49
49
  export const MODAL_ATTR = "data-uixy-modal";
50
+ export const MODAL_ID_ATTR = "data-uixy-modal-id";
50
51
 
51
52
  const modalStack = ref<number[]>([]);
52
53
 
@@ -60,7 +61,11 @@ export const getTopModalEl = (): HTMLElement | null => {
60
61
  if (typeof document === "undefined") return null;
61
62
  const els = Array.from(
62
63
  document.querySelectorAll<HTMLElement>(`[${MODAL_ATTR}]`),
63
- );
64
+ ).filter((el) => {
65
+ const raw = el.getAttribute(MODAL_ID_ATTR);
66
+ if (raw === null) return true;
67
+ return modalStack.value.includes(Number(raw));
68
+ });
64
69
  if (els.length === 0) return null;
65
70
  return els.reduce((a, b) => (zOf(b) >= zOf(a) ? b : a));
66
71
  };
@@ -92,6 +97,7 @@ function reconcileInert() {
92
97
  }
93
98
 
94
99
  export interface UseModalLayerReturn {
100
+ id: number;
95
101
  zIndex: ComputedRef<number>;
96
102
  isTopModal: ComputedRef<boolean>;
97
103
  open: () => void;
@@ -115,10 +121,11 @@ export function useModalLayer(): UseModalLayerReturn {
115
121
  const close = () => {
116
122
  layer.release();
117
123
  modalStack.value = modalStack.value.filter((x) => x !== layer.id);
124
+ reconcileInert();
118
125
  nextTick(reconcileInert);
119
126
  };
120
127
 
121
128
  onScopeDispose(close);
122
129
 
123
- return { zIndex: layer.zIndex, isTopModal, open, close };
130
+ return { id: layer.id, zIndex: layer.zIndex, isTopModal, open, close };
124
131
  }