orio-ui 1.24.0 → 1.27.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 (47) hide show
  1. package/README.md +2 -2
  2. package/dist/module.json +1 -1
  3. package/dist/runtime/components/Button.d.vue.ts +3 -2
  4. package/dist/runtime/components/Button.vue +19 -11
  5. package/dist/runtime/components/Button.vue.d.ts +3 -2
  6. package/dist/runtime/components/Calendar.USAGE.md +51 -0
  7. package/dist/runtime/components/Calendar.vue +254 -87
  8. package/dist/runtime/components/Canvas/USAGE.md +65 -0
  9. package/dist/runtime/components/CheckBox.vue +9 -3
  10. package/dist/runtime/components/CheckboxGroup.vue +7 -1
  11. package/dist/runtime/components/ControlElement.USAGE.md +69 -0
  12. package/dist/runtime/components/ControlElement.d.vue.ts +42 -27
  13. package/dist/runtime/components/ControlElement.vue +28 -9
  14. package/dist/runtime/components/ControlElement.vue.d.ts +42 -27
  15. package/dist/runtime/components/Input.USAGE.md +49 -0
  16. package/dist/runtime/components/Input.vue +13 -3
  17. package/dist/runtime/components/Modal.USAGE.md +64 -0
  18. package/dist/runtime/components/NavButton.d.vue.ts +0 -1
  19. package/dist/runtime/components/NavButton.vue +9 -5
  20. package/dist/runtime/components/NavButton.vue.d.ts +0 -1
  21. package/dist/runtime/components/NumberInput/Horizontal.vue +7 -2
  22. package/dist/runtime/components/NumberInput/Vertical.vue +7 -2
  23. package/dist/runtime/components/NumberInput/index.d.vue.ts +0 -2
  24. package/dist/runtime/components/NumberInput/index.vue +9 -7
  25. package/dist/runtime/components/NumberInput/index.vue.d.ts +0 -2
  26. package/dist/runtime/components/RadioButton.d.vue.ts +0 -2
  27. package/dist/runtime/components/RadioButton.vue +9 -4
  28. package/dist/runtime/components/RadioButton.vue.d.ts +0 -2
  29. package/dist/runtime/components/Selector.d.vue.ts +1 -0
  30. package/dist/runtime/components/Selector.vue +10 -4
  31. package/dist/runtime/components/Selector.vue.d.ts +1 -0
  32. package/dist/runtime/components/SwitchButton.d.vue.ts +1 -4
  33. package/dist/runtime/components/SwitchButton.vue +10 -7
  34. package/dist/runtime/components/SwitchButton.vue.d.ts +1 -4
  35. package/dist/runtime/components/TaggableSelector.vue +7 -1
  36. package/dist/runtime/components/Textarea.vue +13 -3
  37. package/dist/runtime/components/date/Picker.USAGE.md +44 -0
  38. package/dist/runtime/components/date/Picker.vue +7 -1
  39. package/dist/runtime/components/date/PickerTrigger.vue +9 -3
  40. package/dist/runtime/components/date/RangePicker.vue +7 -1
  41. package/dist/runtime/composables/useFilter.d.ts +91 -0
  42. package/dist/runtime/composables/useFilter.js +111 -0
  43. package/dist/runtime/composables/useRovingGrid.d.ts +35 -0
  44. package/dist/runtime/composables/useRovingGrid.js +115 -0
  45. package/dist/runtime/i18n/en.json +4 -1
  46. package/dist/runtime/i18n/uk.json +4 -1
  47. package/package.json +1 -1
@@ -6,7 +6,6 @@ export interface NumberInputProps extends Omit<ControlProps, "layout"> {
6
6
  max?: number;
7
7
  step?: number;
8
8
  decimalPlaces?: number;
9
- disabled?: boolean;
10
9
  }
11
10
  type __VLS_Props = NumberInputProps;
12
11
  declare function increase(): void;
@@ -30,7 +29,6 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
30
29
  "onUpdate:modelValue"?: ((value: number) => any) | undefined;
31
30
  }>, {
32
31
  layout: InputLayout;
33
- disabled: boolean;
34
32
  step: number;
35
33
  min: number;
36
34
  max: number;
@@ -2,8 +2,6 @@ import type { ControlProps } from "./ControlElement.vue.js";
2
2
  export interface RadioButtonProps extends ControlProps {
3
3
  /** The value this radio represents; compared to v-model to determine checked state */
4
4
  value?: unknown;
5
- /** HTML name attribute — groups radios together so only one is selected at a time */
6
- name?: string;
7
5
  /** Inline label text (alternative to default slot) */
8
6
  text?: string;
9
7
  /** Visually hides the label while keeping it accessible to SR (screen readers) */
@@ -2,7 +2,6 @@
2
2
  const modelValue = defineModel({ type: null });
3
3
  const props = defineProps({
4
4
  value: { type: null, required: false },
5
- name: { type: String, required: false },
6
5
  text: { type: String, required: false },
7
6
  hideLabel: { type: Boolean, required: false },
8
7
  appearance: { type: String, required: false },
@@ -12,17 +11,23 @@ const props = defineProps({
12
11
  label: { type: String, required: false },
13
12
  layout: { type: String, required: false },
14
13
  size: { type: String, required: false },
15
- fill: { type: Boolean, required: false }
14
+ fill: { type: Boolean, required: false },
15
+ tabindex: { type: [Number, String], required: false },
16
+ focusKey: { type: String, required: false },
17
+ disabled: { type: Boolean, required: false },
18
+ required: { type: Boolean, required: false },
19
+ name: { type: String, required: false },
20
+ ariaLabel: { type: String, required: false }
16
21
  });
17
22
  </script>
18
23
 
19
24
  <template>
20
- <orio-control-element v-bind="props" class="radio">
25
+ <orio-control-element v-slot="{ control }" v-bind="props" class="radio">
21
26
  <label class="radio-label">
22
27
  <input
23
28
  v-model="modelValue"
29
+ v-bind="control"
24
30
  type="radio"
25
- :name="name"
26
31
  :value="value"
27
32
  class="radio-input"
28
33
  tabindex="-1"
@@ -2,8 +2,6 @@ import type { ControlProps } from "./ControlElement.vue.js";
2
2
  export interface RadioButtonProps extends ControlProps {
3
3
  /** The value this radio represents; compared to v-model to determine checked state */
4
4
  value?: unknown;
5
- /** HTML name attribute — groups radios together so only one is selected at a time */
6
- name?: string;
7
5
  /** Inline label text (alternative to default slot) */
8
6
  text?: string;
9
7
  /** Visually hides the label while keeping it accessible to SR (screen readers) */
@@ -20,6 +20,7 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
20
20
  slots: {
21
21
  trigger?: (props: {
22
22
  toggle: any;
23
+ control: any;
23
24
  }) => any;
24
25
  } & {
25
26
  'trigger-content'?: (props: {
@@ -17,7 +17,13 @@ const props = defineProps({
17
17
  label: { type: String, required: false },
18
18
  layout: { type: String, required: false },
19
19
  size: { type: String, required: false },
20
- fill: { type: Boolean, required: false }
20
+ fill: { type: Boolean, required: false },
21
+ tabindex: { type: [Number, String], required: false },
22
+ focusKey: { type: String, required: false },
23
+ disabled: { type: Boolean, required: false },
24
+ required: { type: Boolean, required: false },
25
+ name: { type: String, required: false },
26
+ ariaLabel: { type: String, required: false }
21
27
  });
22
28
  const { field, optionName } = toRefs(props);
23
29
  const resolvedPlaceholder = computed(
@@ -107,12 +113,12 @@ const {
107
113
  </script>
108
114
 
109
115
  <template>
110
- <orio-control-element v-bind="controlProps">
116
+ <orio-control-element v-slot="{ control }" v-bind="controlProps">
111
117
  <orio-popover position="bottom-right" :offset="5">
112
118
  <template #default="{ toggle, isOpen }">
113
- <slot name="trigger" :toggle>
119
+ <slot name="trigger" :toggle :control>
114
120
  <button
115
- :id="props.id"
121
+ v-bind="control"
116
122
  type="button"
117
123
  class="selector-trigger"
118
124
  aria-haspopup="listbox"
@@ -20,6 +20,7 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
20
20
  slots: {
21
21
  trigger?: (props: {
22
22
  toggle: any;
23
+ control: any;
23
24
  }) => any;
24
25
  } & {
25
26
  'trigger-content'?: (props: {
@@ -1,8 +1,5 @@
1
1
  import type { ControlProps } from "./ControlElement.vue.js";
2
- interface Props extends ControlProps {
3
- disabled?: boolean;
4
- }
5
- type __VLS_Props = Props;
2
+ type __VLS_Props = ControlProps;
6
3
  type __VLS_ModelProps = {
7
4
  modelValue?: boolean;
8
5
  };
@@ -1,6 +1,5 @@
1
1
  <script setup>
2
2
  const props = defineProps({
3
- disabled: { type: Boolean, required: false, default: false },
4
3
  appearance: { type: String, required: false },
5
4
  error: { type: [String, null], required: false },
6
5
  group: { type: Boolean, required: false },
@@ -8,7 +7,13 @@ const props = defineProps({
8
7
  label: { type: String, required: false },
9
8
  layout: { type: String, required: false },
10
9
  size: { type: String, required: false },
11
- fill: { type: Boolean, required: false }
10
+ fill: { type: Boolean, required: false },
11
+ tabindex: { type: [Number, String], required: false },
12
+ focusKey: { type: String, required: false },
13
+ disabled: { type: Boolean, required: false, default: false },
14
+ required: { type: Boolean, required: false },
15
+ name: { type: String, required: false },
16
+ ariaLabel: { type: String, required: false }
12
17
  });
13
18
  const modelValue = defineModel({ type: Boolean, ...{ required: false } });
14
19
  function toggle() {
@@ -18,13 +23,11 @@ function toggle() {
18
23
  </script>
19
24
 
20
25
  <template>
21
- <orio-control-element v-slot="{ id }" v-bind="props">
26
+ <orio-control-element v-slot="{ control }" v-bind="props">
22
27
  <button
23
- :id
24
- v-bind="$attrs"
28
+ v-bind="{ ...$attrs, ...control }"
25
29
  class="switch-button"
26
- :class="{ active: modelValue, disabled }"
27
- :disabled="disabled"
30
+ :class="{ active: modelValue, disabled: props.disabled }"
28
31
  @click="toggle"
29
32
  @keydown.enter.prevent="toggle"
30
33
  @keydown.space.prevent="toggle"
@@ -1,8 +1,5 @@
1
1
  import type { ControlProps } from "./ControlElement.vue.js";
2
- interface Props extends ControlProps {
3
- disabled?: boolean;
4
- }
5
- type __VLS_Props = Props;
2
+ type __VLS_Props = ControlProps;
6
3
  type __VLS_ModelProps = {
7
4
  modelValue?: boolean;
8
5
  };
@@ -12,7 +12,13 @@ const props = defineProps({
12
12
  label: { type: String, required: false },
13
13
  layout: { type: String, required: false },
14
14
  size: { type: String, required: false },
15
- fill: { type: Boolean, required: false }
15
+ fill: { type: Boolean, required: false },
16
+ tabindex: { type: [Number, String], required: false },
17
+ focusKey: { type: String, required: false },
18
+ disabled: { type: Boolean, required: false },
19
+ required: { type: Boolean, required: false },
20
+ name: { type: String, required: false },
21
+ ariaLabel: { type: String, required: false }
16
22
  });
17
23
  const modelValue = defineModel({ type: Array });
18
24
  </script>
@@ -8,18 +8,28 @@ const props = defineProps({
8
8
  id: { type: String, required: false },
9
9
  label: { type: String, required: false },
10
10
  size: { type: String, required: false },
11
- fill: { type: Boolean, required: false }
11
+ fill: { type: Boolean, required: false },
12
+ tabindex: { type: [Number, String], required: false },
13
+ focusKey: { type: String, required: false },
14
+ disabled: { type: Boolean, required: false },
15
+ required: { type: Boolean, required: false },
16
+ name: { type: String, required: false },
17
+ ariaLabel: { type: String, required: false }
12
18
  });
13
19
  </script>
14
20
 
15
21
  <template>
16
22
  <orio-control-element
17
- v-slot="{ id }"
23
+ v-slot="{ control }"
18
24
  v-bind="props"
19
25
  :layout="layout === 'inner' ? 'vertical' : layout"
20
26
  :class="{ inner: layout === 'inner' }"
21
27
  >
22
- <textarea :id v-model="modelValue" rows="4" v-bind="$attrs" />
28
+ <textarea
29
+ v-model="modelValue"
30
+ rows="4"
31
+ v-bind="{ ...$attrs, ...control }"
32
+ />
23
33
  </orio-control-element>
24
34
  </template>
25
35
 
@@ -0,0 +1,44 @@
1
+ # date/Picker — agent-only invariants
2
+
3
+ `<orio-date-picker>` is the single-date picker: a `<orio-date-picker-trigger>`
4
+ button that opens a popover containing `<orio-calendar>`. For ranges use
5
+ `<orio-date-range-picker>`.
6
+
7
+ ## Invariants
8
+
9
+ - **Extends `ControlProps`.** Pass `label`, `error`, `size`, `disabled`,
10
+ `required` straight through — they reach the trigger via ControlElement.
11
+ See `ControlElement.USAGE.md`.
12
+ - **v-model is `string | null`** in ISO `YYYY-MM-DD` form. `null` means
13
+ unpicked.
14
+ - **`min` / `max`** are ISO strings. They merge with the consumer's
15
+ `isDisabled(iso)` callback — Picker's `calendarIsDisabled` returns true
16
+ when either the min/max bound is violated OR the consumer says so.
17
+ - **Selecting a day closes the popover** automatically (`toggle(false)` is
18
+ called inside the `@select` handler). Do not wire your own close.
19
+ - **Markers + getMarker** are forwarded to the inner Calendar unchanged.
20
+ See `Calendar.USAGE.md` for the matching rules.
21
+ - **Placeholder text** falls back to the i18n key `datePicker.placeholder`
22
+ if no `placeholder` prop is given.
23
+
24
+ ## Gotchas
25
+
26
+ - The trigger displays the date via `formatDate(value, locale)` from
27
+ `../../utils/date`. If you need a custom display format, wrap the
28
+ picker — the prop is not exposed.
29
+ - `<orio-date-picker-trigger>` is the popover host. Wiring up your own
30
+ trigger means re-creating popover focus management — prefer composing
31
+ with the existing trigger via its `#default` scoped slot if you need
32
+ custom calendar content (this is exactly how Picker itself works).
33
+
34
+ ## Quick reference
35
+
36
+ ```vue
37
+ <orio-date-picker
38
+ v-model="checkInDate"
39
+ label="Check-in"
40
+ :min="todayIso"
41
+ :max="maxBookingIso"
42
+ :is-disabled="(iso) => blockedDates.has(iso)"
43
+ />
44
+ ```
@@ -16,7 +16,13 @@ const props = defineProps({
16
16
  label: { type: String, required: false },
17
17
  layout: { type: String, required: false },
18
18
  size: { type: String, required: false },
19
- fill: { type: Boolean, required: false }
19
+ fill: { type: Boolean, required: false },
20
+ tabindex: { type: [Number, String], required: false },
21
+ focusKey: { type: String, required: false },
22
+ disabled: { type: Boolean, required: false },
23
+ required: { type: Boolean, required: false },
24
+ name: { type: String, required: false },
25
+ ariaLabel: { type: String, required: false }
20
26
  });
21
27
  const value = defineModel({ type: [String, null], ...{ default: null } });
22
28
  const { locale, t } = useI18n();
@@ -10,7 +10,13 @@ const props = defineProps({
10
10
  label: { type: String, required: false },
11
11
  layout: { type: String, required: false },
12
12
  size: { type: String, required: false },
13
- fill: { type: Boolean, required: false }
13
+ fill: { type: Boolean, required: false },
14
+ tabindex: { type: [Number, String], required: false },
15
+ focusKey: { type: String, required: false },
16
+ disabled: { type: Boolean, required: false },
17
+ required: { type: Boolean, required: false },
18
+ name: { type: String, required: false },
19
+ ariaLabel: { type: String, required: false }
14
20
  });
15
21
  const controlProps = computed(() => {
16
22
  const { text, placeholder, ...rest } = props;
@@ -19,11 +25,11 @@ const controlProps = computed(() => {
19
25
  </script>
20
26
 
21
27
  <template>
22
- <orio-control-element v-slot="{ id }" v-bind="controlProps">
28
+ <orio-control-element v-slot="{ control }" v-bind="controlProps">
23
29
  <orio-popover position="bottom-right" :offset="5">
24
30
  <template #default="{ toggle, isOpen }">
25
31
  <button
26
- :id
32
+ v-bind="control"
27
33
  type="button"
28
34
  class="date-trigger"
29
35
  :aria-expanded="isOpen"
@@ -22,7 +22,13 @@ const props = defineProps({
22
22
  label: { type: String, required: false },
23
23
  layout: { type: String, required: false },
24
24
  size: { type: String, required: false },
25
- fill: { type: Boolean, required: false }
25
+ fill: { type: Boolean, required: false },
26
+ tabindex: { type: [Number, String], required: false },
27
+ focusKey: { type: String, required: false },
28
+ disabled: { type: Boolean, required: false },
29
+ required: { type: Boolean, required: false },
30
+ name: { type: String, required: false },
31
+ ariaLabel: { type: String, required: false }
26
32
  });
27
33
  const range = defineModel({ type: Object, ...{
28
34
  default: () => ({ start: null, end: null })
@@ -0,0 +1,91 @@
1
+ import { type ComputedRef, type Ref } from "vue";
2
+ /**
3
+ * Definition of a single filter inside a group.
4
+ *
5
+ * `value` is both the initial value and the "empty" baseline used to compute
6
+ * `isActive` and to reset to via `clear()`.
7
+ */
8
+ export interface FilterDefinition<Value = unknown> {
9
+ value: Value;
10
+ }
11
+ export type FilterConfig = Record<string, FilterDefinition>;
12
+ export interface FilterOptions {
13
+ /**
14
+ * When true, the group's state is mirrored to URL query params via
15
+ * `useUrlSync`. The dependency is loaded lazily — `useUrlSync` (and its
16
+ * `#imports` use of `useRoute`) is never touched unless this flag is set,
17
+ * keeping `useFilter` runnable outside of a Nuxt context.
18
+ *
19
+ * Filter names become top-level URL keys; avoid colliding names across
20
+ * multiple URL-synced groups on the same page.
21
+ */
22
+ url?: boolean;
23
+ }
24
+ /**
25
+ * Bindable prop bag — spread onto any `v-model`-compatible component:
26
+ * `<orio-selector v-bind="filters.category" :options="..." />`
27
+ */
28
+ export interface FilterBind<Value = unknown> {
29
+ modelValue: Value;
30
+ "onUpdate:modelValue": (value: Value) => void;
31
+ }
32
+ /** Per-filter helpers accessed via `filters.$.<name>`. */
33
+ export interface FilterHelpers<Value = unknown> {
34
+ value: Value;
35
+ initial: Value;
36
+ isActive: boolean;
37
+ clear: () => void;
38
+ }
39
+ export interface ActiveFilter {
40
+ name: string;
41
+ value: unknown;
42
+ clear: () => void;
43
+ }
44
+ export type FilterGroup<Config extends FilterConfig> = {
45
+ [Key in keyof Config]: FilterBind<Config[Key]["value"]>;
46
+ } & {
47
+ $: {
48
+ [Key in keyof Config]: FilterHelpers<Config[Key]["value"]>;
49
+ };
50
+ $active: ComputedRef<ActiveFilter[]>;
51
+ $clearAll: () => void;
52
+ $state: Ref<Record<string, unknown>>;
53
+ };
54
+ /**
55
+ * Define or retrieve a named filter group.
56
+ *
57
+ * Define once anywhere in the page (setup, layout, store). Retrieve the same
58
+ * instance elsewhere by id — any component that knows the id can read and
59
+ * mutate the same reactive state, regardless of where it lives in the tree.
60
+ *
61
+ * @example Define
62
+ * ```ts
63
+ * const filters = useFilter('appointments', {
64
+ * category: { value: null },
65
+ * status: { value: [] as string[] },
66
+ * dateRange: { value: { from: null, to: null } },
67
+ * })
68
+ * ```
69
+ *
70
+ * @example Bind to any v-model component
71
+ * ```vue
72
+ * <orio-selector v-bind="filters.category" :options="categories" />
73
+ * ```
74
+ *
75
+ * @example Retrieve elsewhere
76
+ * ```ts
77
+ * const filters = useFilter('appointments')
78
+ * ```
79
+ *
80
+ * @example Mirror to URL (Nuxt only)
81
+ * ```ts
82
+ * const filters = useFilter('appointments', config, { url: true })
83
+ * ```
84
+ */
85
+ export declare function useFilter<Config extends FilterConfig>(id: string, config: Config, options?: FilterOptions): FilterGroup<Config>;
86
+ export declare function useFilter(id: string): FilterGroup<FilterConfig>;
87
+ /**
88
+ * Remove a filter group from the registry. Use in SPAs where filter groups
89
+ * are page-scoped and should not leak between routes.
90
+ */
91
+ export declare function disposeFilter(id: string): void;
@@ -0,0 +1,111 @@
1
+ import {
2
+ computed,
3
+ effectScope,
4
+ ref
5
+ } from "vue";
6
+ const registry = /* @__PURE__ */ new Map();
7
+ const urlSyncScopes = /* @__PURE__ */ new Map();
8
+ export function useFilter(id, config, options = {}) {
9
+ const existing = registry.get(id);
10
+ if (existing) {
11
+ if (config) {
12
+ console.warn(
13
+ `[useFilter] group "${id}" is already defined \u2014 ignoring new config.`
14
+ );
15
+ }
16
+ return existing;
17
+ }
18
+ if (!config) {
19
+ throw new Error(
20
+ `[useFilter] group "${id}" is not defined. Pass a config on the first call.`
21
+ );
22
+ }
23
+ const initial = {};
24
+ for (const [name, definition] of Object.entries(config)) {
25
+ initial[name] = clone(definition.value);
26
+ }
27
+ const state = ref({ ...initial });
28
+ if (options.url) {
29
+ const scope = effectScope(true);
30
+ urlSyncScopes.set(id, scope);
31
+ void import("./useUrlSync.js").then(({ useUrlSync }) => {
32
+ scope.run(() => useUrlSync(state, Object.keys(config)));
33
+ });
34
+ }
35
+ const handle = {};
36
+ const helpers = {};
37
+ for (const name of Object.keys(config)) {
38
+ helpers[name] = {
39
+ get value() {
40
+ return state.value[name];
41
+ },
42
+ get initial() {
43
+ return initial[name];
44
+ },
45
+ get isActive() {
46
+ return !isEqual(state.value[name], initial[name]);
47
+ },
48
+ clear() {
49
+ state.value[name] = clone(initial[name]);
50
+ }
51
+ };
52
+ Object.defineProperty(handle, name, {
53
+ enumerable: true,
54
+ value: {
55
+ get modelValue() {
56
+ return state.value[name];
57
+ },
58
+ "onUpdate:modelValue": (value) => {
59
+ state.value[name] = value;
60
+ }
61
+ }
62
+ });
63
+ }
64
+ Object.defineProperty(handle, "$", { value: helpers });
65
+ Object.defineProperty(handle, "$active", {
66
+ value: computed(
67
+ () => Object.keys(config).flatMap((name) => {
68
+ const helper = helpers[name];
69
+ return helper.isActive ? [{ name, value: helper.value, clear: helper.clear }] : [];
70
+ })
71
+ )
72
+ });
73
+ Object.defineProperty(handle, "$clearAll", {
74
+ value: () => {
75
+ for (const name of Object.keys(config)) {
76
+ state.value[name] = clone(initial[name]);
77
+ }
78
+ }
79
+ });
80
+ Object.defineProperty(handle, "$state", { value: state });
81
+ registry.set(id, handle);
82
+ return handle;
83
+ }
84
+ export function disposeFilter(id) {
85
+ urlSyncScopes.get(id)?.stop();
86
+ urlSyncScopes.delete(id);
87
+ registry.delete(id);
88
+ }
89
+ function clone(value) {
90
+ if (value === null || typeof value !== "object") return value;
91
+ return structuredClone(value);
92
+ }
93
+ function isEqual(a, b) {
94
+ if (a === b) return true;
95
+ if (a === null || b === null) return false;
96
+ if (typeof a !== typeof b) return false;
97
+ if (typeof a !== "object") return false;
98
+ if (Array.isArray(a)) {
99
+ if (!Array.isArray(b) || a.length !== b.length) return false;
100
+ return a.every((item, index) => isEqual(item, b[index]));
101
+ }
102
+ const keysA = Object.keys(a);
103
+ const keysB = Object.keys(b);
104
+ if (keysA.length !== keysB.length) return false;
105
+ return keysA.every(
106
+ (key) => isEqual(
107
+ a[key],
108
+ b[key]
109
+ )
110
+ );
111
+ }
@@ -0,0 +1,35 @@
1
+ import { type Ref } from "vue";
2
+ export type ArrowDirection = "up" | "down" | "left" | "right";
3
+ export type PageDirection = "up" | "down";
4
+ export interface RovingGridOptions<Cell> {
5
+ rows: Ref<Cell[][]>;
6
+ gridRef: Ref<HTMLElement | null>;
7
+ getKey: (cell: Cell) => string;
8
+ initial: () => string;
9
+ /**
10
+ * Cells where this returns `false` are skipped by arrow navigation —
11
+ * pressing Arrow steps past them in the same direction until a navigable
12
+ * cell is found (or the grid edge is reached, then `onArrowOverflow` fires).
13
+ * Default: every cell is navigable.
14
+ */
15
+ isNavigable?: (cell: Cell) => boolean;
16
+ onActivate?: (cell: Cell) => void;
17
+ /**
18
+ * Called when an arrow key would move past the rendered grid edge.
19
+ * Return a new key to focus (caller should update any backing state, e.g.
20
+ * paging to a new month, before returning). Return null to do nothing.
21
+ */
22
+ onArrowOverflow?: (direction: ArrowDirection, activeKey: string) => string | null;
23
+ /**
24
+ * Called for PageUp / PageDown (with Shift = larger jump).
25
+ * Return a new key to focus, or null to do nothing.
26
+ */
27
+ onPage?: (direction: PageDirection, bigJump: boolean, activeKey: string) => string | null;
28
+ }
29
+ export declare function useRovingGrid<Cell>(options: RovingGridOptions<Cell>): {
30
+ activeKey: import("vue").ComputedRef<string>;
31
+ setActive: (key: string, shouldFocus?: boolean) => void;
32
+ focusActive: () => void;
33
+ onKeydown: (event: KeyboardEvent) => void;
34
+ tabindexFor: (key: string) => 0 | -1;
35
+ };