@omnitend/dashboard-for-laravel 0.33.1 → 0.35.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 (57) hide show
  1. package/dist/charts.js +82 -90
  2. package/dist/charts.js.map +1 -1
  3. package/dist/charts.umd.cjs +1 -1
  4. package/dist/charts.umd.cjs.map +1 -1
  5. package/dist/components/base/DButton.vue.d.ts +1 -1
  6. package/dist/components/charts/DXBarChart.vue.d.ts +3 -18
  7. package/dist/components/charts/DXLineChart.vue.d.ts +3 -18
  8. package/dist/components/charts/useThemedChart.d.ts +35 -0
  9. package/dist/components/extended/DXChoiceField.vue.d.ts +26 -0
  10. package/dist/components/extended/DXDashboardSidebar.vue.d.ts +1 -1
  11. package/dist/components/extended/DXField.vue.d.ts +10 -113
  12. package/dist/components/extended/DXFieldShell.vue.d.ts +73 -0
  13. package/dist/components/extended/DXForm.vue.d.ts +28 -6
  14. package/dist/components/extended/DXNumericField.vue.d.ts +23 -0
  15. package/dist/components/extended/DXRepeater.vue.d.ts +4 -4
  16. package/dist/components/extended/DXRepeaterCards.vue.d.ts +45 -0
  17. package/dist/components/extended/DXTable.vue.d.ts +107 -2
  18. package/dist/components/extended/DXTableEditorModal.vue.d.ts +22 -2
  19. package/dist/components/extended/DXUserAvatar.vue.d.ts +1 -1
  20. package/dist/composables/useAsyncOptions.d.ts +20 -0
  21. package/dist/composables/useContainerWidth.d.ts +96 -0
  22. package/dist/composables/useResourceEditor.d.ts +2 -1
  23. package/dist/dashboard-for-laravel.js +10513 -10443
  24. package/dist/dashboard-for-laravel.js.map +1 -1
  25. package/dist/dashboard-for-laravel.umd.cjs +7 -7
  26. package/dist/dashboard-for-laravel.umd.cjs.map +1 -1
  27. package/dist/index.d.ts +5 -2
  28. package/dist/style.css +1 -1
  29. package/dist/types/index.d.ts +146 -0
  30. package/dist/utils/formSchema.d.ts +59 -0
  31. package/docs/public/api-reference.json +494 -33
  32. package/docs/public/docs-map.md +1 -1
  33. package/docs/public/llms.txt +5 -2
  34. package/package.json +1 -1
  35. package/resources/css/theme.scss +80 -2
  36. package/resources/js/components/charts/DXBarChart.vue +4 -43
  37. package/resources/js/components/charts/DXLineChart.vue +4 -43
  38. package/resources/js/components/charts/useThemedChart.ts +69 -0
  39. package/resources/js/components/extended/DXChoiceField.vue +114 -0
  40. package/resources/js/components/extended/DXDashboardSidebar.vue +1 -1
  41. package/resources/js/components/extended/DXField.vue +328 -615
  42. package/resources/js/components/extended/DXFieldShell.vue +124 -0
  43. package/resources/js/components/extended/DXForm.vue +92 -14
  44. package/resources/js/components/extended/DXNumericField.vue +144 -0
  45. package/resources/js/components/extended/DXRepeater.vue +53 -175
  46. package/resources/js/components/extended/DXRepeaterCards.vue +133 -0
  47. package/resources/js/components/extended/DXTable.vue +418 -43
  48. package/resources/js/components/extended/DXTableEditorModal.vue +39 -2
  49. package/resources/js/components/extended/DXTablePagination.vue +19 -3
  50. package/resources/js/components/extended/DXTableShell.vue +70 -1
  51. package/resources/js/composables/defineForm.ts +8 -44
  52. package/resources/js/composables/useAsyncOptions.ts +61 -0
  53. package/resources/js/composables/useContainerWidth.ts +303 -0
  54. package/resources/js/composables/useResourceEditor.ts +24 -38
  55. package/resources/js/index.ts +40 -0
  56. package/resources/js/types/index.ts +231 -0
  57. package/resources/js/utils/formSchema.ts +126 -0
@@ -0,0 +1,20 @@
1
+ import { type ComputedRef, type Ref } from "vue";
2
+ import type { FieldDefinition, FieldOption } from "../types";
3
+ /**
4
+ * Async option loading for a `DXField`: runs `field.optionsLoader` on mount and
5
+ * (when `field.reloadOptionsOnChange` is set) whenever the model changes,
6
+ * exposing the loaded options. A monotonic request token guards against
7
+ * out-of-order responses clobbering newer ones; loader failures are swallowed
8
+ * so the last good options (or the static `field.options` fallback) stay put.
9
+ *
10
+ * Extracted verbatim from DXField's inline logic (#135) — behaviour unchanged.
11
+ * `getField` is an accessor (props aren't destructurable without losing
12
+ * reactivity); `effectiveModel` is the model passed to the loader.
13
+ */
14
+ export interface UseAsyncOptionsReturn {
15
+ /** Options returned by the most recent successful load, or null if none yet. */
16
+ loadedOptions: Ref<FieldOption[] | null>;
17
+ /** Trigger a load (no-op when the field has no `optionsLoader`). */
18
+ loadOptions: () => Promise<void>;
19
+ }
20
+ export declare function useAsyncOptions(getField: () => FieldDefinition, effectiveModel: ComputedRef<any> | Ref<any>): UseAsyncOptionsReturn;
@@ -0,0 +1,96 @@
1
+ /**
2
+ * useContainerWidth — container-query-style responsiveness for Vue components.
3
+ *
4
+ * Bootstrap's breakpoints are **media** queries: they only ever see the WINDOW.
5
+ * A dashboard page is narrowed by the persistent sidebar (and a form inside a
6
+ * modal is narrower still), so a component can have very little room while the
7
+ * viewport is wide — and no media query ever fires. This composable closes that
8
+ * gap by observing an element's **own rendered width** with a `ResizeObserver`
9
+ * and exposing it reactively, so the template can pick a layout from the space
10
+ * it actually has.
11
+ *
12
+ * ```ts
13
+ * const { containerRef, width, isBelow, isNarrowerThan } = useContainerWidth({
14
+ * threshold: 640,
15
+ * });
16
+ * // <div ref="containerRef"> … </div>
17
+ * ```
18
+ *
19
+ * One observer can drive several independent decisions — `isBelow` uses the
20
+ * configured `threshold`, and `isNarrowerThan(n)` answers for any other width:
21
+ *
22
+ * ```ts
23
+ * const stacked = computed(() => isNarrowerThan(576));
24
+ * const hideDetailColumn = computed(() => isNarrowerThan(900));
25
+ * ```
26
+ */
27
+ import { type Ref } from "vue";
28
+ /**
29
+ * What to observe: a template ref, or a getter (so the element can be resolved
30
+ * lazily / conditionally — e.g. `() => enabled ? el.value : null` to observe
31
+ * nothing at all).
32
+ */
33
+ export type ContainerWidthTarget = Ref<HTMLElement | null | undefined> | (() => HTMLElement | null | undefined);
34
+ export interface UseContainerWidthOptions {
35
+ /**
36
+ * Width (px) that `isBelow` compares against. Omit if you only need
37
+ * `width` / `isNarrowerThan`. Pass a getter (`() => props.threshold`) when
38
+ * it can change at runtime — `isBelow` re-evaluates when it does.
39
+ */
40
+ threshold?: number | (() => number | undefined);
41
+ /**
42
+ * Hysteresis band (px) applied to `isBelow` only, to stop a layout flipping
43
+ * back and forth at the boundary. Once `isBelow` is true it stays true
44
+ * until the width reaches `threshold + hysteresis`.
45
+ *
46
+ * Defaults to `0` so `isBelow` means exactly `width < threshold` unless you
47
+ * ask for otherwise. Opt in whenever the layout you drive from it can
48
+ * change the observed width — the classic loop is: narrow layout is taller
49
+ * → an ancestor with `overflow:auto` gains a vertical scrollbar → the
50
+ * container loses ~15-17px → it crosses back over the threshold → repeat.
51
+ * A band wider than a scrollbar (24px is comfortable) breaks that cycle.
52
+ * (`isNarrowerThan` is deliberately raw — it holds no per-width state.)
53
+ */
54
+ hysteresis?: number;
55
+ /**
56
+ * Width assumed before the first measurement, and permanently where there
57
+ * is no `ResizeObserver` (SSR, or a very old browser).
58
+ *
59
+ * Defaults to `0` — i.e. "assume the narrowest until proven otherwise", so
60
+ * an unmeasured render picks the STACKED layout. That is the mobile-first
61
+ * choice and the safe one: a stacked layout is legible at every width,
62
+ * whereas a wide layout guessed wrongly truncates content. It also means
63
+ * the server-rendered markup matches the first client render.
64
+ */
65
+ initialWidth?: number;
66
+ /**
67
+ * Which box to report. `content-box` (default) is the space actually
68
+ * available to children — what a layout decision usually wants.
69
+ * `border-box` matches `getBoundingClientRect().width`.
70
+ */
71
+ box?: "content-box" | "border-box";
72
+ /**
73
+ * Extra debounce (ms) before publishing a new width. Defaults to `0`:
74
+ * `ResizeObserver` already batches to one delivery per frame, and the
75
+ * callback reads the size the observer *hands* it (no forced layout), so
76
+ * there is nothing to thrash. Set it only for genuinely expensive
77
+ * downstream work — a timer adds a frame of visible lag.
78
+ */
79
+ debounce?: number;
80
+ }
81
+ export interface UseContainerWidthReturn {
82
+ /** Bind to the element you want measured (`<div ref="containerRef">`). */
83
+ containerRef: Ref<HTMLElement | null>;
84
+ /** The observed width in px. `initialWidth` until first measured. */
85
+ width: Readonly<Ref<number>>;
86
+ /** False until a real measurement has landed (always false without a `ResizeObserver`). */
87
+ hasMeasured: Readonly<Ref<boolean>>;
88
+ /** `width < threshold`, with `hysteresis` applied. False when no `threshold` was given. */
89
+ isBelow: Readonly<Ref<boolean>>;
90
+ /** Raw `width < px`, for driving other decisions off the same observer. */
91
+ isNarrowerThan: (px: number) => boolean;
92
+ /** Disconnect early. Called automatically when the owning scope is disposed. */
93
+ stop: () => void;
94
+ }
95
+ export declare function useContainerWidth(options?: UseContainerWidthOptions): UseContainerWidthReturn;
96
+ export declare function useContainerWidth(target: ContainerWidthTarget, options?: UseContainerWidthOptions): UseContainerWidthReturn;
@@ -1,4 +1,5 @@
1
1
  import { type Ref } from "vue";
2
+ import type { FieldDefinition } from "../types";
2
3
  /**
3
4
  * The subset of `DXTable`'s props the resource editor reads. Declared
4
5
  * structurally (not imported from DXTable.vue) so the composable stays a
@@ -7,7 +8,7 @@ import { type Ref } from "vue";
7
8
  */
8
9
  export interface ResourceEditorProps<T = any> {
9
10
  /** Field definitions for the edit/create modal (enables edit-on-row-click). */
10
- editFields?: any[];
11
+ editFields?: FieldDefinition[];
11
12
  /** Tab definitions — only their `key` is read here (DXForm consumes the rest). */
12
13
  editTabs?: Array<{
13
14
  key: string;