@nexdom/uimed-vue 2.0.0-beta.27 → 2.0.0-beta.28

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 (2) hide show
  1. package/dist/components.js +52 -4
  2. package/package.json +1 -1
@@ -1366,6 +1366,15 @@ var checkbox_default = /* @__PURE__ */ defineComponent({
1366
1366
  //#endregion
1367
1367
  //#region src/composables/inputs/date-time-field.ts
1368
1368
  /**
1369
+ * The menu's content is a dialog with the pickers. `aria-owns` is removed since the input can't
1370
+ * own the content, and the menu still adds `aria-expanded` and `aria-controls`.
1371
+ */
1372
+ const activatorProps = {
1373
+ role: "combobox",
1374
+ "aria-haspopup": "dialog",
1375
+ "aria-owns": void 0
1376
+ };
1377
+ /**
1369
1378
  * Extracts the date part (`YYYY-MM-DD`) of a value, or an empty string when
1370
1379
  * the type has no date.
1371
1380
  */
@@ -1423,6 +1432,31 @@ function useDateTimeFieldPickerBounds(props, selectedDate) {
1423
1432
  };
1424
1433
  });
1425
1434
  }
1435
+ /**
1436
+ * Makes the field's input the activator of the pickers' menu, so the menu's attributes are on an
1437
+ * element whose role accepts them.
1438
+ * @param isOpen - Whether the menu is open.
1439
+ * @param isDisabled - Whether the menu can't open, as when the field is disabled or readonly.
1440
+ * @param hasLabel - Whether the field has a label, which names the menu's dialog.
1441
+ */
1442
+ function useDateTimeFieldMenu(isOpen, isDisabled, hasLabel) {
1443
+ const inputId = useId();
1444
+ const activator = computed(() => toValue(isDisabled) ? void 0 : `#${inputId}`);
1445
+ const contentProps = computed(() => ({
1446
+ role: "dialog",
1447
+ "aria-labelledby": toValue(hasLabel) ? `${inputId}-label` : void 0
1448
+ }));
1449
+ function open() {
1450
+ if (!toValue(isDisabled)) isOpen.value = true;
1451
+ }
1452
+ return {
1453
+ inputId,
1454
+ activator,
1455
+ activatorProps,
1456
+ contentProps,
1457
+ open
1458
+ };
1459
+ }
1426
1460
  function getTimeBound(bound, type, selectedDate) {
1427
1461
  if (type === "datetime" && getDatePart(bound, type) !== selectedDate) return "";
1428
1462
  return getTimePart(bound, type);
@@ -1518,6 +1552,7 @@ var date_time_field_default = /* @__PURE__ */ defineComponent({
1518
1552
  const draftTime = computed(() => draft.value.time ?? getTimePart(modelValue.value, props.type));
1519
1553
  const draftValue = computed(() => joinDateTime(props.type, draftDate.value, draftTime.value));
1520
1554
  const bounds = useDateTimeFieldPickerBounds(props, draftDate);
1555
+ const { inputId, activator, activatorProps, contentProps, open: openMenu } = useDateTimeFieldMenu(isMenuOpen, isMenuDisabled, () => !!props.label);
1521
1556
  watch(isMenuOpen, () => {
1522
1557
  draft.value = {};
1523
1558
  });
@@ -1541,6 +1576,7 @@ var date_time_field_default = /* @__PURE__ */ defineComponent({
1541
1576
  }
1542
1577
  return (_ctx, _cache) => {
1543
1578
  return openBlock(), createBlock(unref(VTextField), {
1579
+ id: unref(inputId),
1544
1580
  "model-value": displayValue.value,
1545
1581
  "validation-value": modelValue.value,
1546
1582
  variant: unref(vuetifyVariant),
@@ -1554,13 +1590,17 @@ var date_time_field_default = /* @__PURE__ */ defineComponent({
1554
1590
  hint: props.hint,
1555
1591
  clearable: isClearable.value,
1556
1592
  readonly: "",
1557
- "onClick:clear": clear
1593
+ "onClick:clear": clear,
1594
+ "onClick:control": unref(openMenu)
1558
1595
  }, {
1559
1596
  loader: withCtx((loader) => [createVNode(field_loader_default, normalizeProps(guardReactiveProps(loader)), null, 16)]),
1560
1597
  default: withCtx(() => [createVNode(unref(VMenu), {
1561
1598
  modelValue: isMenuOpen.value,
1562
1599
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isMenuOpen.value = $event),
1563
- activator: "parent",
1600
+ activator: unref(activator),
1601
+ target: "parent",
1602
+ "activator-props": unref(activatorProps),
1603
+ "content-props": unref(contentProps),
1564
1604
  location: "bottom start",
1565
1605
  "min-width": "0",
1566
1606
  disabled: isMenuDisabled.value,
@@ -1600,9 +1640,16 @@ var date_time_field_default = /* @__PURE__ */ defineComponent({
1600
1640
  _: 1
1601
1641
  })]),
1602
1642
  _: 1
1603
- }, 8, ["modelValue", "disabled"])]),
1643
+ }, 8, [
1644
+ "modelValue",
1645
+ "activator",
1646
+ "activator-props",
1647
+ "content-props",
1648
+ "disabled"
1649
+ ])]),
1604
1650
  _: 1
1605
1651
  }, 8, [
1652
+ "id",
1606
1653
  "model-value",
1607
1654
  "validation-value",
1608
1655
  "variant",
@@ -1614,7 +1661,8 @@ var date_time_field_default = /* @__PURE__ */ defineComponent({
1614
1661
  "label",
1615
1662
  "placeholder",
1616
1663
  "hint",
1617
- "clearable"
1664
+ "clearable",
1665
+ "onClick:control"
1618
1666
  ]);
1619
1667
  };
1620
1668
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexdom/uimed-vue",
3
- "version": "2.0.0-beta.27",
3
+ "version": "2.0.0-beta.28",
4
4
  "description": "A ui framework for NEXDOM applications.",
5
5
  "keywords": [
6
6
  "lib",