akar 1.16.0 → 1.18.0

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 (55) hide show
  1. package/dist/calendar/calendar-root.js +6 -5
  2. package/dist/calendar/calendar-root.js.map +1 -1
  3. package/dist/combobox/combobox-content-impl.js +2 -1
  4. package/dist/combobox/combobox-content-impl.js.map +1 -1
  5. package/dist/date/calendar.date.js +25 -11
  6. package/dist/date/calendar.date.js.map +1 -1
  7. package/dist/date/comparators.date.js +10 -2
  8. package/dist/date/comparators.date.js.map +1 -1
  9. package/dist/date/use-date-field.js +59 -20
  10. package/dist/date/use-date-field.js.map +1 -1
  11. package/dist/date-picker/date-picker-root.js +10 -8
  12. package/dist/date-picker/date-picker-root.js.map +1 -1
  13. package/dist/date-range-picker/date-range-picker-root.js +11 -9
  14. package/dist/date-range-picker/date-range-picker-root.js.map +1 -1
  15. package/dist/date.d.ts +2 -2
  16. package/dist/date.js +2 -2
  17. package/dist/focus-scope/focus-scope.js +2 -2
  18. package/dist/focus-scope/focus-scope.js.map +1 -1
  19. package/dist/focus-scope/stack.js +1 -4
  20. package/dist/focus-scope/stack.js.map +1 -1
  21. package/dist/index.d.ts +799 -800
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index2.d.ts +9 -2
  24. package/dist/index2.d.ts.map +1 -1
  25. package/dist/range-calendar/range-calendar-root.js +6 -5
  26. package/dist/range-calendar/range-calendar-root.js.map +1 -1
  27. package/dist/shared/use-grace-area.js +1 -1
  28. package/dist/shared/use-grace-area.js.map +1 -1
  29. package/dist/time-field/time-field-input.js +3 -1
  30. package/dist/time-field/time-field-input.js.map +1 -1
  31. package/dist/time-field/time-field-root.js +26 -2
  32. package/dist/time-field/time-field-root.js.map +1 -1
  33. package/package.json +7 -6
  34. package/src/calendar/calendar-root.vue +12 -11
  35. package/src/calendar/use-calendar.ts +2 -2
  36. package/src/combobox/combobox-content-impl.vue +1 -0
  37. package/src/combobox/combobox-root.vue +1 -1
  38. package/src/date/calendar.date.ts +42 -18
  39. package/src/date/comparators.date.ts +11 -3
  40. package/src/date-picker/date-picker-anchor.vue +2 -2
  41. package/src/date-picker/date-picker-arrow.vue +2 -2
  42. package/src/date-picker/date-picker-close.vue +2 -2
  43. package/src/date-picker/date-picker-root.vue +11 -11
  44. package/src/date-picker/index.ts +71 -27
  45. package/src/date-range-picker/date-range-picker-root.vue +14 -15
  46. package/src/focus-scope/focus-scope.vue +2 -2
  47. package/src/index.ts +1 -0
  48. package/src/listbox/listbox-filter.vue +1 -1
  49. package/src/listbox/listbox-root.vue +1 -1
  50. package/src/range-calendar/range-calendar-root.vue +14 -14
  51. package/src/shared/date/use-date-field.ts +104 -21
  52. package/src/shared/use-grace-area.ts +1 -1
  53. package/src/time-field/time-field-input.vue +7 -2
  54. package/src/time-field/time-field-root.vue +42 -3
  55. package/src/tree/tree-root.vue +2 -2
@@ -1,6 +1,5 @@
1
1
  <script lang="ts">
2
2
  import type { DateValue } from '@internationalized/date';
3
-
4
3
  import type { Ref } from 'vue';
5
4
  import type { APrimitiveProps } from '../primitive';
6
5
  import type { UseDateFormatter } from '../shared';
@@ -35,6 +34,7 @@ type TimeFieldRootContext = {
35
34
  formatter: UseDateFormatter;
36
35
  hourCycle: HourCycle;
37
36
  step: Ref<DateStep>;
37
+ stepSnapping: Ref<boolean>;
38
38
  segmentValues: Ref<SegmentValueObj>;
39
39
  segmentContents: Ref<Array<{ part: SegmentPart; value: string }>>;
40
40
  elements: Ref<Set<HTMLElement>>;
@@ -55,6 +55,8 @@ export interface ATimeFieldRootProps extends APrimitiveProps, FormFieldProps {
55
55
  hourCycle?: HourCycle;
56
56
  /** The stepping interval for the time fields. Defaults to `1`. */
57
57
  step?: DateStep;
58
+ /** Whether to enforce snapping the value to the nearest step increment after input. Defaults to `false`. */
59
+ stepSnapping?: boolean;
58
60
  /** The granularity to use for formatting times. Defaults to minute if a Time is provided, otherwise defaults to minute. The field will render segments for each part of the date up to and including the specified granularity */
59
61
  granularity?: 'hour' | 'minute' | 'second';
60
62
  /** Whether or not to hide the time zone segment of the field */
@@ -110,7 +112,9 @@ const props = withDefaults(defineProps<ATimeFieldRootProps>(), {
110
112
  readonly: false,
111
113
  placeholder: undefined,
112
114
  isDateUnavailable: undefined,
115
+ stepSnapping: false,
113
116
  });
117
+
114
118
  const emits = defineEmits<ATimeFieldRootEmits>();
115
119
  defineSlots<{
116
120
  default?: (props: {
@@ -123,7 +127,17 @@ defineSlots<{
123
127
  }) => any;
124
128
  }>();
125
129
 
126
- const { disabled, readonly, granularity, defaultValue, minValue, maxValue, dir: propDir, locale: propLocale } = toRefs(props);
130
+ const {
131
+ disabled,
132
+ readonly,
133
+ granularity,
134
+ defaultValue,
135
+ minValue,
136
+ maxValue,
137
+ stepSnapping,
138
+ dir: propDir,
139
+ locale: propLocale,
140
+ } = toRefs(props);
127
141
  const locale = useLocale(propLocale);
128
142
  const dir = useDirection(propDir);
129
143
 
@@ -227,7 +241,31 @@ const allSegmentContent = computed(() => createContent({
227
241
  isTimeValue: true,
228
242
  }));
229
243
 
230
- const segmentContents = computed(() => allSegmentContent.value.arr);
244
+ const segmentContents = computed(() => {
245
+ const contents = allSegmentContent.value.arr;
246
+
247
+ // Convert hour values for 12-hour display
248
+ if (props.hourCycle === 12) {
249
+ return contents.map((segment) => {
250
+ if (segment.part === 'hour' && 'hour' in segmentValues.value) {
251
+ const hour = segmentValues.value.hour;
252
+ if (hour !== null) {
253
+ let displayHour = hour;
254
+ if (hour === 0) {
255
+ displayHour = 12;
256
+ } else if (hour > 12) {
257
+ displayHour = hour - 12;
258
+ }
259
+
260
+ return { ...segment, value: displayHour.toString() };
261
+ }
262
+ }
263
+ return segment;
264
+ });
265
+ }
266
+
267
+ return contents;
268
+ });
231
269
 
232
270
  const editableSegmentContents = computed(() => segmentContents.value.filter(({ part }) => part !== 'literal'));
233
271
 
@@ -320,6 +358,7 @@ provideTimeFieldRootContext({
320
358
  hourCycle: props.hourCycle,
321
359
  readonly,
322
360
  step,
361
+ stepSnapping,
323
362
  segmentValues,
324
363
  isInvalid,
325
364
  segmentContents: editableSegmentContents,
@@ -3,13 +3,13 @@ import type { Direction } from '../shared/types';
3
3
  import { createContext, getActiveElement, useDirection, useSelectionBehavior, useTypeahead } from '../shared';
4
4
 
5
5
  export interface ATreeRootProps<T = Record<string, any>, U extends Record<string, any> = Record<string, any>, M extends boolean = false> extends APrimitiveProps {
6
- /** The controlled value of the tree. Can be binded with with `v-model`. */
6
+ /** The controlled value of the tree. Can be binded with `v-model`. */
7
7
  modelValue?: M extends true ? Array<U> : U;
8
8
  /** The value of the tree when initially rendered. Use when you do not need to control the state of the tree */
9
9
  defaultValue?: M extends true ? Array<U> : U;
10
10
  /** List of items */
11
11
  items?: Array<T>;
12
- /** The controlled value of the expanded item. Can be binded with with `v-model`. */
12
+ /** The controlled value of the expanded item. Can be binded with `v-model`. */
13
13
  expanded?: Array<string>;
14
14
  /** The value of the expanded tree when initially rendered. Use when you do not need to control the state of the expanded tree */
15
15
  defaultExpanded?: Array<string>;