@omnitend/dashboard-for-laravel 0.33.0 → 0.34.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.
- package/dist/charts.js +82 -90
- package/dist/charts.js.map +1 -1
- package/dist/charts.umd.cjs +1 -1
- package/dist/charts.umd.cjs.map +1 -1
- package/dist/components/base/DButton.vue.d.ts +1 -1
- package/dist/components/charts/DXBarChart.vue.d.ts +3 -18
- package/dist/components/charts/DXLineChart.vue.d.ts +3 -18
- package/dist/components/charts/useThemedChart.d.ts +35 -0
- package/dist/components/extended/DXChoiceField.vue.d.ts +26 -0
- package/dist/components/extended/DXDashboardSidebar.vue.d.ts +1 -1
- package/dist/components/extended/DXField.vue.d.ts +10 -113
- package/dist/components/extended/DXFieldShell.vue.d.ts +73 -0
- package/dist/components/extended/DXNumericField.vue.d.ts +23 -0
- package/dist/components/extended/DXRepeater.vue.d.ts +4 -4
- package/dist/components/extended/DXRepeaterCards.vue.d.ts +45 -0
- package/dist/components/extended/DXTable.vue.d.ts +91 -2
- package/dist/components/extended/DXTableEditorModal.vue.d.ts +17 -2
- package/dist/components/extended/DXUserAvatar.vue.d.ts +1 -1
- package/dist/composables/useAsyncOptions.d.ts +20 -0
- package/dist/composables/useResourceEditor.d.ts +2 -1
- package/dist/dashboard-for-laravel.js +9987 -10054
- package/dist/dashboard-for-laravel.js.map +1 -1
- package/dist/dashboard-for-laravel.umd.cjs +7 -7
- package/dist/dashboard-for-laravel.umd.cjs.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/style.css +1 -1
- package/dist/types/index.d.ts +146 -0
- package/dist/utils/formSchema.d.ts +59 -0
- package/docs/public/api-reference.json +464 -30
- package/docs/public/docs-map.md +1 -1
- package/docs/public/llms.txt +5 -2
- package/package.json +1 -1
- package/resources/js/components/charts/DXBarChart.vue +4 -43
- package/resources/js/components/charts/DXLineChart.vue +4 -43
- package/resources/js/components/charts/useThemedChart.ts +69 -0
- package/resources/js/components/extended/DXChoiceField.vue +114 -0
- package/resources/js/components/extended/DXField.vue +328 -615
- package/resources/js/components/extended/DXFieldShell.vue +124 -0
- package/resources/js/components/extended/DXForm.vue +9 -5
- package/resources/js/components/extended/DXNumericField.vue +144 -0
- package/resources/js/components/extended/DXRepeater.vue +53 -175
- package/resources/js/components/extended/DXRepeaterCards.vue +133 -0
- package/resources/js/components/extended/DXTable.vue +250 -37
- package/resources/js/components/extended/DXTableEditorModal.vue +34 -2
- package/resources/js/composables/defineForm.ts +8 -44
- package/resources/js/composables/useAsyncOptions.ts +61 -0
- package/resources/js/composables/useResourceEditor.ts +24 -38
- package/resources/js/index.ts +33 -0
- package/resources/js/types/index.ts +231 -0
- package/resources/js/utils/formSchema.ts +126 -0
package/dist/types/index.d.ts
CHANGED
|
@@ -308,6 +308,151 @@ export interface FieldDefinition {
|
|
|
308
308
|
*/
|
|
309
309
|
show?: () => boolean;
|
|
310
310
|
}
|
|
311
|
+
/** Options common to every field variant (the non-`type`-specific props). */
|
|
312
|
+
export interface BaseFieldDef {
|
|
313
|
+
key: string;
|
|
314
|
+
label?: MaybeFn<string>;
|
|
315
|
+
required?: boolean;
|
|
316
|
+
help?: string;
|
|
317
|
+
hint?: MaybeFn<string>;
|
|
318
|
+
info?: MaybeFn<string>;
|
|
319
|
+
class?: string;
|
|
320
|
+
inputProps?: Record<string, any>;
|
|
321
|
+
span?: boolean;
|
|
322
|
+
layout?: "vertical" | "horizontal";
|
|
323
|
+
labelCols?: LabelCols;
|
|
324
|
+
hideLabel?: boolean;
|
|
325
|
+
default?: any;
|
|
326
|
+
disabled?: MaybeFn<boolean>;
|
|
327
|
+
disabledWhen?: (model: any) => boolean;
|
|
328
|
+
readonly?: MaybeFn<boolean>;
|
|
329
|
+
plaintext?: MaybeFn<boolean>;
|
|
330
|
+
submit?: boolean;
|
|
331
|
+
when?: MaybeFn<boolean>;
|
|
332
|
+
show?: () => boolean;
|
|
333
|
+
}
|
|
334
|
+
/** Mixins shared by several variants (not exported — internal composition). */
|
|
335
|
+
interface WithPlaceholder {
|
|
336
|
+
placeholder?: string;
|
|
337
|
+
}
|
|
338
|
+
interface WithNumericBounds {
|
|
339
|
+
step?: number | string;
|
|
340
|
+
min?: number | string;
|
|
341
|
+
max?: number | string;
|
|
342
|
+
}
|
|
343
|
+
interface WithSelectableOptions {
|
|
344
|
+
options?: FieldOption[];
|
|
345
|
+
optionsLoader?: OptionsLoader;
|
|
346
|
+
reloadOptionsOnChange?: boolean;
|
|
347
|
+
}
|
|
348
|
+
/** `text` / `email` / `url` / `tel` — a plain text-like `<input>`. */
|
|
349
|
+
export interface TextFieldDef extends BaseFieldDef, WithPlaceholder {
|
|
350
|
+
type: "text" | "email" | "url" | "tel";
|
|
351
|
+
}
|
|
352
|
+
/** `password` — text input with an optional reveal (eye) toggle. */
|
|
353
|
+
export interface PasswordFieldDef extends BaseFieldDef, WithPlaceholder {
|
|
354
|
+
type: "password";
|
|
355
|
+
revealable?: boolean;
|
|
356
|
+
}
|
|
357
|
+
/** `number` — numeric input with optional bounds. */
|
|
358
|
+
export interface NumberFieldDef extends BaseFieldDef, WithPlaceholder, WithNumericBounds {
|
|
359
|
+
type: "number";
|
|
360
|
+
}
|
|
361
|
+
/** `date` / `datetime` / `datetime-local` / `time` — native date/time controls.
|
|
362
|
+
* `min`/`max`/`step` are valid on these inputs (e.g. `min="2024-01-01"`) and
|
|
363
|
+
* DXField forwards them, so the variant permits them. */
|
|
364
|
+
export interface DateFieldDef extends BaseFieldDef, WithNumericBounds {
|
|
365
|
+
type: "date" | "datetime" | "datetime-local" | "time";
|
|
366
|
+
}
|
|
367
|
+
/** `currency` — numeric input with a symbol affix and minor-unit handling. */
|
|
368
|
+
export interface CurrencyFieldDef extends BaseFieldDef, WithPlaceholder, WithNumericBounds {
|
|
369
|
+
type: "currency";
|
|
370
|
+
currencySymbol?: string;
|
|
371
|
+
decimals?: number;
|
|
372
|
+
minorUnits?: boolean;
|
|
373
|
+
}
|
|
374
|
+
/** `percentage` — numeric input shown as a 0–100 percentage. */
|
|
375
|
+
export interface PercentageFieldDef extends BaseFieldDef, WithPlaceholder, WithNumericBounds {
|
|
376
|
+
type: "percentage";
|
|
377
|
+
asFraction?: boolean;
|
|
378
|
+
}
|
|
379
|
+
/** `textarea` — multi-line text input. */
|
|
380
|
+
export interface TextareaFieldDef extends BaseFieldDef, WithPlaceholder {
|
|
381
|
+
type: "textarea";
|
|
382
|
+
rows?: number;
|
|
383
|
+
}
|
|
384
|
+
/** `select` — dropdown; `searchable` upgrades it to a filterable select. */
|
|
385
|
+
export interface SelectFieldDef extends BaseFieldDef, WithPlaceholder, WithSelectableOptions {
|
|
386
|
+
type: "select";
|
|
387
|
+
searchable?: boolean;
|
|
388
|
+
}
|
|
389
|
+
/** `autocomplete` — free-text input with datalist suggestions. */
|
|
390
|
+
export interface AutocompleteFieldDef extends BaseFieldDef, WithPlaceholder, WithSelectableOptions {
|
|
391
|
+
type: "autocomplete";
|
|
392
|
+
}
|
|
393
|
+
/** `checkbox` — a single boolean checkbox. */
|
|
394
|
+
export interface CheckboxFieldDef extends BaseFieldDef {
|
|
395
|
+
type: "checkbox";
|
|
396
|
+
}
|
|
397
|
+
/** `checkbox-group` — multiple checkboxes; model is an array of values. */
|
|
398
|
+
export interface CheckboxGroupFieldDef extends BaseFieldDef, WithSelectableOptions {
|
|
399
|
+
type: "checkbox-group";
|
|
400
|
+
}
|
|
401
|
+
/** `switch` — a toggle with contextual on/off text and on-state colour. */
|
|
402
|
+
export interface SwitchFieldDef extends BaseFieldDef {
|
|
403
|
+
type: "switch";
|
|
404
|
+
textWhenTrue?: MaybeFn<string>;
|
|
405
|
+
textWhenFalse?: MaybeFn<string>;
|
|
406
|
+
switchVariant?: "success" | "neutral";
|
|
407
|
+
}
|
|
408
|
+
/** `switch-list` — a labelled toggle row per option; model is an array. */
|
|
409
|
+
export interface SwitchListFieldDef extends BaseFieldDef, WithSelectableOptions {
|
|
410
|
+
type: "switch-list";
|
|
411
|
+
switchVariant?: "success" | "neutral";
|
|
412
|
+
}
|
|
413
|
+
/** `radio` — a radio group. */
|
|
414
|
+
export interface RadioFieldDef extends BaseFieldDef, WithSelectableOptions {
|
|
415
|
+
type: "radio";
|
|
416
|
+
}
|
|
417
|
+
/** `image` / `file` — file input (`image` also shows a preview). */
|
|
418
|
+
export interface FileFieldDef extends BaseFieldDef {
|
|
419
|
+
type: "image" | "file";
|
|
420
|
+
accept?: string;
|
|
421
|
+
}
|
|
422
|
+
/** `component` — escape hatch rendering `field.component`. */
|
|
423
|
+
export interface ComponentFieldDef extends BaseFieldDef {
|
|
424
|
+
type: "component";
|
|
425
|
+
/** Required on the strict variant: a `component` field with no component
|
|
426
|
+
* falls through to the generic input branch, so the union enforces it. */
|
|
427
|
+
component: Component;
|
|
428
|
+
}
|
|
429
|
+
/** `repeater` — a nested, repeatable sub-form driven by `fields`. */
|
|
430
|
+
export interface RepeaterFieldDef extends BaseFieldDef {
|
|
431
|
+
type: "repeater";
|
|
432
|
+
fields?: FieldDef[];
|
|
433
|
+
addLabel?: string;
|
|
434
|
+
minItems?: number;
|
|
435
|
+
maxItems?: number;
|
|
436
|
+
repeaterLayout?: "cards" | "table";
|
|
437
|
+
showRowIndex?: boolean;
|
|
438
|
+
softDeleteKey?: string;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Strict, discriminated replacement for `FieldDefinition`. Keyed on `type`,
|
|
442
|
+
* so each field only permits its own options. Opt-in today; canonical in a
|
|
443
|
+
* future major (#131). See the banner above.
|
|
444
|
+
*/
|
|
445
|
+
export type FieldDef = TextFieldDef | PasswordFieldDef | NumberFieldDef | DateFieldDef | CurrencyFieldDef | PercentageFieldDef | TextareaFieldDef | SelectFieldDef | AutocompleteFieldDef | CheckboxFieldDef | CheckboxGroupFieldDef | SwitchFieldDef | SwitchListFieldDef | RadioFieldDef | FileFieldDef | ComponentFieldDef | RepeaterFieldDef;
|
|
446
|
+
/**
|
|
447
|
+
* Compile-time drift guard (#131): every strict variant must remain assignable
|
|
448
|
+
* to the permissive `FieldDefinition`. If a `FieldDef` variant grows a prop that
|
|
449
|
+
* `FieldDefinition` doesn't have (or types incompatibly), this fails to satisfy
|
|
450
|
+
* its `true` constraint and the build goes red. Purely type-level — no runtime.
|
|
451
|
+
* (The reverse direction — a prop added to `FieldDefinition` but forgotten on a
|
|
452
|
+
* variant — can't be asserted this way; the banner above is the reminder.)
|
|
453
|
+
*/
|
|
454
|
+
type _AssertTrue<T extends true> = T;
|
|
455
|
+
export type _FieldDefStaysASubset = _AssertTrue<FieldDef extends FieldDefinition ? true : false>;
|
|
311
456
|
/**
|
|
312
457
|
* A tab in a tabbed form. Groups a subset of fields and can be shown
|
|
313
458
|
* conditionally or lazily mounted.
|
|
@@ -329,3 +474,4 @@ export interface FormTab {
|
|
|
329
474
|
/** Lazily mount tab content until first activated */
|
|
330
475
|
lazy?: boolean;
|
|
331
476
|
}
|
|
477
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { FieldType, MaybeFn } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* The canonical starting value for a field TYPE, used when a field declares no
|
|
4
|
+
* explicit `default`. Superset of the previous copies:
|
|
5
|
+
* - `checkbox` / `switch` → `false`
|
|
6
|
+
* - `number` / `currency` / `percentage` → `0`
|
|
7
|
+
* - `repeater` / `checkbox-group` / `switch-list` → `[]` (array-valued models)
|
|
8
|
+
* - `image` / `file` → `null`
|
|
9
|
+
* - everything else (text family, `select`, `radio`, `autocomplete`, …) → `""`
|
|
10
|
+
*/
|
|
11
|
+
export declare function defaultValueForType(type: FieldType): any;
|
|
12
|
+
/**
|
|
13
|
+
* Deep-clone a default so object/array defaults aren't shared BY REFERENCE
|
|
14
|
+
* across form instances or repeater rows (mutating one row would otherwise
|
|
15
|
+
* mutate the field's declared default and every sibling row).
|
|
16
|
+
*
|
|
17
|
+
* Mirrors `useForm`'s `deepClone`: `toRaw` unwraps a Vue reactive proxy, then
|
|
18
|
+
* `structuredClone` (which preserves Date/File/Map — a plain JSON round-trip
|
|
19
|
+
* would flatten a `Date` default to a string) with a JSON fallback for a
|
|
20
|
+
* residual nested proxy or otherwise-uncloneable value. This matters because
|
|
21
|
+
* `defineForm`/`useResourceEditor` now clone here BEFORE the value reaches
|
|
22
|
+
* `useForm`, so a lossy clone would corrupt a rich default the raw path used
|
|
23
|
+
* to preserve (#134 review).
|
|
24
|
+
*/
|
|
25
|
+
export declare function cloneDefault<TValue>(value: TValue): TValue;
|
|
26
|
+
/**
|
|
27
|
+
* A field's starting value: its explicit `default` (deep-cloned) when one is
|
|
28
|
+
* DEFINED, else the type default. Definedness — not nullishness — decides, so a
|
|
29
|
+
* legitimate `null` default (e.g. a "none" select option whose value is `null`)
|
|
30
|
+
* survives instead of being replaced by the type default (#122/#125). An absent
|
|
31
|
+
* or explicitly-`undefined` default falls back to the type default rather than
|
|
32
|
+
* seeding `undefined`, which would drop the key from the JSON payload.
|
|
33
|
+
*/
|
|
34
|
+
export declare function resolveFieldDefault(field: {
|
|
35
|
+
type: FieldType;
|
|
36
|
+
default?: any;
|
|
37
|
+
}): any;
|
|
38
|
+
/**
|
|
39
|
+
* Resolve a `MaybeFn<boolean>` predicate (`when` on a field or tab) against the
|
|
40
|
+
* live model. `undefined` yields `fallback` (the field/tab is unconditioned).
|
|
41
|
+
*/
|
|
42
|
+
export declare function resolvePredicate(when: MaybeFn<boolean> | undefined, model: any, fallback: boolean): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Whether a field is VISIBLE against a model, by the one rule every renderer
|
|
45
|
+
* shares: the `when` predicate (default visible) AND the legacy no-arg `show`
|
|
46
|
+
* predicate. A field is visible only if both pass.
|
|
47
|
+
*/
|
|
48
|
+
export declare function isFieldVisible(field: {
|
|
49
|
+
when?: MaybeFn<boolean>;
|
|
50
|
+
show?: () => boolean;
|
|
51
|
+
}, model: any): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Whether a field's value belongs in the submitted payload. A presentational
|
|
54
|
+
* field (`submit: false`) — a header, an alert, an explanatory `span` block —
|
|
55
|
+
* renders but holds no data and must not be POSTed just because it was declared.
|
|
56
|
+
*/
|
|
57
|
+
export declare function isSubmittableField(field: {
|
|
58
|
+
submit?: boolean;
|
|
59
|
+
}): boolean;
|