@middag-io/react 0.51.0 → 0.52.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-lib/{DateField-lPZsiWfC.js → DateField-CduB6lUv.js} +21 -23
- package/dist-lib/{DateRangeField-B7zWB48D.js → DateRangeField-DlA_9i4w.js} +17 -13
- package/dist-lib/{FormField-BGqAQLtX.js → FormField-CDdY7-md.js} +2090 -2054
- package/dist-lib/{FormPanelBlock-CGgA83Mu.js → FormPanelBlock-zo8tCgtS.js} +1 -2
- package/dist-lib/base/blocks/CardGridBlock.d.ts.map +1 -1
- package/dist-lib/base/blocks/DenseTableBlock.d.ts.map +1 -1
- package/dist-lib/base/blocks/EmptyStateBlock.d.ts.map +1 -1
- package/dist-lib/base/blocks/FormPanelBlock.d.ts.map +1 -1
- package/dist-lib/base/blocks/MetricCardBlock.d.ts.map +1 -1
- package/dist-lib/base/form/FormField.d.ts +8 -1
- package/dist-lib/base/form/FormField.d.ts.map +1 -1
- package/dist-lib/base/form/fields/DateField.d.ts +1 -1
- package/dist-lib/base/form/fields/DateField.d.ts.map +1 -1
- package/dist-lib/base/form/fields/DateRangeField.d.ts +3 -1
- package/dist-lib/base/form/fields/DateRangeField.d.ts.map +1 -1
- package/dist-lib/base/form/fields/MultiSelectField.d.ts +3 -1
- package/dist-lib/base/form/fields/MultiSelectField.d.ts.map +1 -1
- package/dist-lib/base/form/fields/RadioField.d.ts +3 -1
- package/dist-lib/base/form/fields/RadioField.d.ts.map +1 -1
- package/dist-lib/base/form/fields/RatingField.d.ts +3 -1
- package/dist-lib/base/form/fields/RatingField.d.ts.map +1 -1
- package/dist-lib/base/form/fields/SliderField.d.ts +3 -1
- package/dist-lib/base/form/fields/SliderField.d.ts.map +1 -1
- package/dist-lib/base/form/fields/TagsField.d.ts.map +1 -1
- package/dist-lib/base/partials/DataTable/cell-renderers.d.ts.map +1 -1
- package/dist-lib/base/partials/DataTable/index.d.ts.map +1 -1
- package/dist-lib/base/partials/DataTable/types.d.ts +2 -2
- package/dist-lib/base/partials/DataTable/types.d.ts.map +1 -1
- package/dist-lib/base/partials/EmptyPlaceholder/index.d.ts.map +1 -1
- package/dist-lib/base/shell/BasicShell.d.ts +12 -1
- package/dist-lib/base/shell/BasicShell.d.ts.map +1 -1
- package/dist-lib/base/shell/BasicShell.js +126 -111
- package/dist-lib/base/shell/partials/InlineEditablePanel.js +193 -176
- package/dist-lib/base/shell/partials/InspectorContext.js +1 -1
- package/dist-lib/base/theme/tailwind-theme.css +13 -5
- package/dist-lib/base/theme/theme-bridge.css +8 -0
- package/dist-lib/base/theme/themes/classic.css +15 -11
- package/dist-lib/base/theme/tokens.css +36 -10
- package/dist-lib/base/utils/php-wire.d.ts +33 -0
- package/dist-lib/base/utils/php-wire.d.ts.map +1 -0
- package/dist-lib/base/utils/php-wire.js +19 -0
- package/dist-lib/chunks/{subpath-DjkzcIPp.js → subpath-Bb5vw3A_.js} +21 -23
- package/dist-lib/chunks/{subpath-fEhy6n_U.js → subpath-CZB5_RY7.js} +2 -0
- package/dist-lib/chunks/subpath-DVHs9lfh.js +29 -0
- package/dist-lib/contracts/block-data/data-display.d.ts +12 -287
- package/dist-lib/contracts/block-data/data-display.d.ts.map +1 -1
- package/dist-lib/contracts/block-data/interactive.d.ts +14 -22
- package/dist-lib/contracts/block-data/interactive.d.ts.map +1 -1
- package/dist-lib/contracts/block-data/shared.d.ts +2 -17
- package/dist-lib/contracts/block-data/shared.d.ts.map +1 -1
- package/dist-lib/contracts/generated/index.d.ts +2 -2
- package/dist-lib/contracts/generated/schemas.d.ts +1584 -192
- package/dist-lib/contracts/generated/schemas.d.ts.map +1 -1
- package/dist-lib/contracts/generated/types.d.ts +288 -8
- package/dist-lib/contracts/generated/types.d.ts.map +1 -1
- package/dist-lib/contracts/page-contract-schema.d.ts +15 -0
- package/dist-lib/contracts/page-contract-schema.d.ts.map +1 -1
- package/dist-lib/i18n/I18nProvider.js +1 -1
- package/dist-lib/i18n/instance.js +1 -1
- package/dist-lib/i18n/locales/en/ui.json +1 -0
- package/dist-lib/i18n/locales/pt-BR/ui.json +1 -0
- package/dist-lib/i18n/register-strings.js +1 -1
- package/dist-lib/index.d.ts +2 -2
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/lib/hooks/use-prefers-reduced-motion.d.ts +6 -0
- package/dist-lib/lib/hooks/use-prefers-reduced-motion.d.ts.map +1 -0
- package/dist-lib/lib/hooks/use-prefers-reduced-motion.js +21 -0
- package/dist-lib/middag-react.css +1 -1
- package/dist-lib/middag-react.js +10423 -10010
- package/dist-lib/primitives/reui/badge.d.ts +5 -0
- package/dist-lib/primitives/reui/badge.d.ts.map +1 -1
- package/dist-lib/primitives/reui/badge.js +14 -14
- package/dist-lib/primitives/reui/sidebar.d.ts.map +1 -1
- package/dist-lib/primitives/reui/sidebar.js +46 -34
- package/docs/public/schemas/fragment.json +1258 -19
- package/docs/public/schemas/page-contract.json +1258 -19
- package/docs/public/schemas/shared-props.json +1258 -19
- package/package.json +6 -1
- package/src/base/blocks/CardGridBlock.tsx +10 -2
- package/src/base/blocks/DenseTableBlock.tsx +45 -14
- package/src/base/blocks/DetailPanelBlock.tsx +1 -1
- package/src/base/blocks/EmptyStateBlock.tsx +5 -1
- package/src/base/blocks/FormPanelBlock.tsx +0 -1
- package/src/base/blocks/MetricCardBlock.tsx +9 -2
- package/src/base/form/FormField.tsx +40 -7
- package/src/base/form/fields/DateField.tsx +3 -3
- package/src/base/form/fields/DateRangeField.tsx +19 -14
- package/src/base/form/fields/MultiSelectField.tsx +9 -8
- package/src/base/form/fields/RadioField.tsx +4 -0
- package/src/base/form/fields/RatingField.tsx +4 -0
- package/src/base/form/fields/SliderField.tsx +4 -1
- package/src/base/form/fields/TagsField.tsx +3 -0
- package/src/base/partials/DataTable/cell-renderers.tsx +23 -12
- package/src/base/partials/DataTable/index.tsx +5 -2
- package/src/base/partials/DataTable/types.ts +2 -5
- package/src/base/partials/DetailSection/index.tsx +2 -2
- package/src/base/partials/EmptyPlaceholder/index.tsx +7 -3
- package/src/base/partials/MarkdownContent/index.tsx +1 -1
- package/src/base/shell/BasicShell.tsx +47 -8
- package/src/base/shell/partials/InspectorContext.tsx +1 -1
- package/src/base/theme/tailwind-theme.css +13 -5
- package/src/base/theme/theme-bridge.css +8 -0
- package/src/base/theme/themes/classic.css +15 -11
- package/src/base/theme/tokens.css +36 -10
- package/src/base/utils/php-wire.ts +54 -0
- package/src/contracts/block-data/data-display.ts +46 -337
- package/src/contracts/block-data/interactive.ts +18 -23
- package/src/contracts/block-data/shared.ts +2 -14
- package/src/contracts/generated/index.ts +2 -2
- package/src/contracts/generated/schemas.ts +312 -9
- package/src/contracts/generated/types.ts +314 -8
- package/src/i18n/locales/en/ui.json +1 -0
- package/src/i18n/locales/pt-BR/ui.json +1 -0
- package/src/lib/hooks/use-prefers-reduced-motion.ts +32 -0
- package/src/primitives/reui/badge.tsx +19 -14
- package/src/primitives/reui/sidebar.tsx +30 -3
- package/src/theme.css +11 -5
- package/dist-lib/chunks/subpath-DoiyWIYV.js +0 -25
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* Regenerate: npm run gen:contracts
|
|
8
8
|
* Drift gate: npm run gen:contracts:check
|
|
9
9
|
*
|
|
10
|
-
* @source middag-io/middag-php-ui@
|
|
10
|
+
* @source middag-io/middag-php-ui@v2.0.0-rc.2 schema/{page-contract.json,fragment.json,shared-props.json}
|
|
11
11
|
* @contract-version 2
|
|
12
|
-
* @hash
|
|
12
|
+
* @hash 78e6ca38e09436d5
|
|
13
13
|
*/
|
|
14
14
|
export type Label = string | Translatable;
|
|
15
15
|
export type ActionTarget =
|
|
@@ -316,8 +316,22 @@ export type OptionFieldProps = FieldPropsBase & {
|
|
|
316
316
|
}[];
|
|
317
317
|
};
|
|
318
318
|
export type RegionUpdateMode = "replace" | "append" | "prepend" | "remove" | "update";
|
|
319
|
-
export type
|
|
319
|
+
export type ConditionalActionVariant = "icon" | "button" | (string & {});
|
|
320
|
+
export type CardGridVariant = "default" | "store" | "connector" | (string & {});
|
|
321
|
+
export type TimestampFormat = "relative" | "datetime" | "date" | "time" | "iso" | (string & {});
|
|
322
|
+
export type StatusIntent =
|
|
323
|
+
| "success"
|
|
324
|
+
| "warning"
|
|
325
|
+
| "destructive"
|
|
326
|
+
| "secondary"
|
|
327
|
+
| "info"
|
|
328
|
+
| "default"
|
|
329
|
+
| (string & {});
|
|
330
|
+
export type DeltaDirection = "positive" | "negative" | "neutral" | (string & {});
|
|
331
|
+
export type EmptyStateVariant = "first-use" | "no-results" | "error" | "permission" | (string & {});
|
|
332
|
+
export type StatusStripTone = "success" | "warning" | "danger" | "neutral" | (string & {});
|
|
320
333
|
export type ChartType = "line" | "bar" | "area" | (string & {});
|
|
334
|
+
export type ActionTargetKind = "link" | "route" | "request" | "panel";
|
|
321
335
|
export type ConditionOperator =
|
|
322
336
|
| "eq"
|
|
323
337
|
| "neq"
|
|
@@ -408,6 +422,12 @@ export interface PageContract {
|
|
|
408
422
|
entities?: {
|
|
409
423
|
[k: string]: string;
|
|
410
424
|
};
|
|
425
|
+
help?: {
|
|
426
|
+
title: string;
|
|
427
|
+
body: string;
|
|
428
|
+
learnMore?: string;
|
|
429
|
+
};
|
|
430
|
+
inspector?: InspectorDescriptor;
|
|
411
431
|
}
|
|
412
432
|
export interface PageMeta {
|
|
413
433
|
key: string;
|
|
@@ -490,6 +510,11 @@ export interface Notification {
|
|
|
490
510
|
timeout?: number;
|
|
491
511
|
action?: Action;
|
|
492
512
|
}
|
|
513
|
+
export interface InspectorDescriptor {
|
|
514
|
+
endpoint: string;
|
|
515
|
+
width: number;
|
|
516
|
+
poll?: PollConfig;
|
|
517
|
+
}
|
|
493
518
|
export interface Fragment {
|
|
494
519
|
version: "2";
|
|
495
520
|
kind: FragmentKind;
|
|
@@ -499,11 +524,6 @@ export interface Fragment {
|
|
|
499
524
|
notifications?: Notification[];
|
|
500
525
|
customType?: string;
|
|
501
526
|
}
|
|
502
|
-
export interface InspectorDescriptor {
|
|
503
|
-
endpoint: string;
|
|
504
|
-
width: number;
|
|
505
|
-
poll?: PollConfig;
|
|
506
|
-
}
|
|
507
527
|
export interface EditablePanelDescriptor {
|
|
508
528
|
endpoint: string;
|
|
509
529
|
submitEndpoint?: string;
|
|
@@ -720,4 +740,290 @@ export interface ActionResult {
|
|
|
720
740
|
errors?: FormErrors;
|
|
721
741
|
fragments?: Fragment[];
|
|
722
742
|
}
|
|
743
|
+
export interface ConditionalAction {
|
|
744
|
+
id: string;
|
|
745
|
+
label: Label;
|
|
746
|
+
target: ActionTarget;
|
|
747
|
+
intent: ActionIntent;
|
|
748
|
+
icon?: string;
|
|
749
|
+
confirmation?: Confirmation;
|
|
750
|
+
capability?: string;
|
|
751
|
+
disabled?: true;
|
|
752
|
+
loading?: true;
|
|
753
|
+
variant?: ConditionalActionVariant;
|
|
754
|
+
visible_when?: FormCondition;
|
|
755
|
+
disabled_when?: FormCondition;
|
|
756
|
+
loading_when?: FormCondition;
|
|
757
|
+
disabled_reason_field?: string;
|
|
758
|
+
}
|
|
759
|
+
export interface EmptyStateDef {
|
|
760
|
+
icon?: string;
|
|
761
|
+
title?: string;
|
|
762
|
+
description?: string;
|
|
763
|
+
cta?: {
|
|
764
|
+
label: string;
|
|
765
|
+
href: string;
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
export interface CardGridBlockData {
|
|
769
|
+
columns: CardGridColumnDef[];
|
|
770
|
+
rows: (
|
|
771
|
+
| {
|
|
772
|
+
[k: string]: unknown;
|
|
773
|
+
}
|
|
774
|
+
| []
|
|
775
|
+
)[];
|
|
776
|
+
variant?: CardGridVariant;
|
|
777
|
+
emptyState?: EmptyStateDef;
|
|
778
|
+
editHref?: string;
|
|
779
|
+
rowActions?: ConditionalAction[];
|
|
780
|
+
}
|
|
781
|
+
export interface CardGridColumnDef {
|
|
782
|
+
key: string;
|
|
783
|
+
label: string;
|
|
784
|
+
kind?: "text" | "status" | "badge" | "boolean" | "timestamp" | "number";
|
|
785
|
+
}
|
|
786
|
+
export interface EntityRef {
|
|
787
|
+
type: string;
|
|
788
|
+
id: string;
|
|
789
|
+
}
|
|
790
|
+
export interface DenseTableColumnDef {
|
|
791
|
+
key: string;
|
|
792
|
+
label: string;
|
|
793
|
+
sortable?: boolean;
|
|
794
|
+
searchable?: boolean;
|
|
795
|
+
variant?: ColumnVariant | string;
|
|
796
|
+
timestampFormat?: TimestampFormat;
|
|
797
|
+
href?: string;
|
|
798
|
+
entity?: EntityRef;
|
|
799
|
+
minWidth?: number;
|
|
800
|
+
maxWidth?: number;
|
|
801
|
+
statusMap?:
|
|
802
|
+
| {
|
|
803
|
+
[k: string]: StatusIntent;
|
|
804
|
+
}
|
|
805
|
+
| [];
|
|
806
|
+
format?: ValueFormat;
|
|
807
|
+
formatOptions?:
|
|
808
|
+
| {
|
|
809
|
+
[k: string]: unknown;
|
|
810
|
+
}
|
|
811
|
+
| [];
|
|
812
|
+
options?:
|
|
813
|
+
| {
|
|
814
|
+
[k: string]: unknown;
|
|
815
|
+
}
|
|
816
|
+
| [];
|
|
817
|
+
}
|
|
818
|
+
export interface DenseTablePagination {
|
|
819
|
+
page: number;
|
|
820
|
+
perPage: number;
|
|
821
|
+
total: number;
|
|
822
|
+
lastPage: number;
|
|
823
|
+
}
|
|
824
|
+
export interface DenseTableSort {
|
|
825
|
+
column: string | null;
|
|
826
|
+
direction: "asc" | "desc" | null;
|
|
827
|
+
}
|
|
828
|
+
export interface DenseTableFilterDef {
|
|
829
|
+
key: string;
|
|
830
|
+
label: string;
|
|
831
|
+
type: "select" | "multiselect" | "date_range";
|
|
832
|
+
options?: {
|
|
833
|
+
value: string;
|
|
834
|
+
label: string;
|
|
835
|
+
}[];
|
|
836
|
+
}
|
|
837
|
+
export interface DenseTableBlockData {
|
|
838
|
+
columns: DenseTableColumnDef[];
|
|
839
|
+
rows: (
|
|
840
|
+
| {
|
|
841
|
+
[k: string]: unknown;
|
|
842
|
+
}
|
|
843
|
+
| []
|
|
844
|
+
)[];
|
|
845
|
+
pagination?: DenseTablePagination;
|
|
846
|
+
sort?: DenseTableSort;
|
|
847
|
+
filters?:
|
|
848
|
+
| {
|
|
849
|
+
available: DenseTableFilterDef[];
|
|
850
|
+
applied:
|
|
851
|
+
| {
|
|
852
|
+
[k: string]: string | string[];
|
|
853
|
+
}
|
|
854
|
+
| [];
|
|
855
|
+
}
|
|
856
|
+
| [];
|
|
857
|
+
rowHref?: string;
|
|
858
|
+
rowActions?: ConditionalAction[];
|
|
859
|
+
bulkActions?: Action[];
|
|
860
|
+
searchPlaceholder?: string;
|
|
861
|
+
emptyState?: EmptyStateDef;
|
|
862
|
+
saveViewAction?: Action;
|
|
863
|
+
saveViewActive?: boolean;
|
|
864
|
+
options?: TableDisplayOptions;
|
|
865
|
+
}
|
|
866
|
+
export interface RichStatusValue {
|
|
867
|
+
label: string;
|
|
868
|
+
appearance: "success" | "warning" | "danger" | "info" | "neutral";
|
|
869
|
+
icon?: string;
|
|
870
|
+
}
|
|
871
|
+
export interface AnnotatedValue {
|
|
872
|
+
text: string;
|
|
873
|
+
badge?: {
|
|
874
|
+
label: string;
|
|
875
|
+
color: string;
|
|
876
|
+
};
|
|
877
|
+
sublabel?: string;
|
|
878
|
+
appearance?: "success" | "warning" | "danger" | "info" | "neutral";
|
|
879
|
+
}
|
|
880
|
+
export interface ProgressValue {
|
|
881
|
+
value: number;
|
|
882
|
+
max?: number;
|
|
883
|
+
label?: string;
|
|
884
|
+
appearance?: "success" | "warning" | "danger" | "info" | "neutral";
|
|
885
|
+
}
|
|
886
|
+
export interface LinkGroupItem {
|
|
887
|
+
icon: string;
|
|
888
|
+
href: string | null;
|
|
889
|
+
label: string;
|
|
890
|
+
external?: boolean;
|
|
891
|
+
}
|
|
892
|
+
export interface MetricCardBlockData {
|
|
893
|
+
value: string | number;
|
|
894
|
+
delta?: string;
|
|
895
|
+
deltaDirection?: DeltaDirection;
|
|
896
|
+
label: string;
|
|
897
|
+
icon?: string;
|
|
898
|
+
href?: string;
|
|
899
|
+
locale?: string;
|
|
900
|
+
compact?: boolean;
|
|
901
|
+
}
|
|
902
|
+
export interface EmptyStateBlockData {
|
|
903
|
+
variant?: EmptyStateVariant;
|
|
904
|
+
icon?: string;
|
|
905
|
+
lottieUrl?: string;
|
|
906
|
+
description?: string;
|
|
907
|
+
cta?: {
|
|
908
|
+
label: string;
|
|
909
|
+
href?: string;
|
|
910
|
+
method?: "get" | "post";
|
|
911
|
+
};
|
|
912
|
+
ctaSecondary?: {
|
|
913
|
+
label: string;
|
|
914
|
+
href: string;
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
export interface StatusStripItem {
|
|
918
|
+
key: string;
|
|
919
|
+
label: string;
|
|
920
|
+
value: string;
|
|
921
|
+
appearance: "success" | "warning" | "danger" | "info" | "neutral";
|
|
922
|
+
tooltip?: string;
|
|
923
|
+
href?: string;
|
|
924
|
+
}
|
|
925
|
+
export interface StatusStripBlockData {
|
|
926
|
+
score?: number;
|
|
927
|
+
tone?: StatusStripTone;
|
|
928
|
+
items: StatusStripItem[];
|
|
929
|
+
}
|
|
930
|
+
export interface DetailPanelFieldDef {
|
|
931
|
+
key: string;
|
|
932
|
+
label: string;
|
|
933
|
+
value: string | number | boolean | null;
|
|
934
|
+
kind?: "text" | "status" | "timestamp" | "boolean" | "link" | "code" | "email";
|
|
935
|
+
copyable?: boolean;
|
|
936
|
+
href?: string;
|
|
937
|
+
entity?: {
|
|
938
|
+
type: string;
|
|
939
|
+
id: string | number;
|
|
940
|
+
};
|
|
941
|
+
}
|
|
942
|
+
export interface DetailPanelSectionDef {
|
|
943
|
+
id: string;
|
|
944
|
+
title: string;
|
|
945
|
+
fields: DetailPanelFieldDef[];
|
|
946
|
+
defaultCollapsed?: boolean;
|
|
947
|
+
actions?: Action[];
|
|
948
|
+
}
|
|
949
|
+
export interface DetailPanelBlockData {
|
|
950
|
+
sections: DetailPanelSectionDef[];
|
|
951
|
+
columns?: 1 | 2;
|
|
952
|
+
}
|
|
953
|
+
export interface ActivityTimelineEntry {
|
|
954
|
+
id: string;
|
|
955
|
+
actor: string;
|
|
956
|
+
actorHref?: string;
|
|
957
|
+
action: string;
|
|
958
|
+
detail?: string;
|
|
959
|
+
icon: string;
|
|
960
|
+
color: "success" | "info" | "warning" | "destructive" | "neutral";
|
|
961
|
+
timestamp: number;
|
|
962
|
+
read?: boolean;
|
|
963
|
+
markReadHref?: string;
|
|
964
|
+
}
|
|
965
|
+
export interface ActivityTimelineBlockData {
|
|
966
|
+
groups: {
|
|
967
|
+
label: string;
|
|
968
|
+
entries: ActivityTimelineEntry[];
|
|
969
|
+
}[];
|
|
970
|
+
hasMore?: boolean;
|
|
971
|
+
loadMoreHref?: string;
|
|
972
|
+
limit?: number;
|
|
973
|
+
}
|
|
974
|
+
export interface MarkdownPanelBlockData {
|
|
975
|
+
content: string;
|
|
976
|
+
maxHeight?: number;
|
|
977
|
+
}
|
|
978
|
+
export interface LinkListItem {
|
|
979
|
+
label: string;
|
|
980
|
+
href: string | null;
|
|
981
|
+
icon?: string;
|
|
982
|
+
description?: string;
|
|
983
|
+
external?: boolean;
|
|
984
|
+
trailing?: string;
|
|
985
|
+
active?: boolean;
|
|
986
|
+
}
|
|
987
|
+
export interface LinkListBlockData {
|
|
988
|
+
items: LinkListItem[];
|
|
989
|
+
}
|
|
990
|
+
export interface ChartBlockData {
|
|
991
|
+
chartType: ChartType;
|
|
992
|
+
categoryKey: string;
|
|
993
|
+
series: ChartSeries[];
|
|
994
|
+
data: (
|
|
995
|
+
| {
|
|
996
|
+
[k: string]: unknown;
|
|
997
|
+
}
|
|
998
|
+
| []
|
|
999
|
+
)[];
|
|
1000
|
+
options?: {
|
|
1001
|
+
showLegend?: boolean;
|
|
1002
|
+
showGrid?: boolean;
|
|
1003
|
+
};
|
|
1004
|
+
}
|
|
1005
|
+
export interface TabsBlockData {
|
|
1006
|
+
tabs: Tab[];
|
|
1007
|
+
defaultTab?: string;
|
|
1008
|
+
}
|
|
1009
|
+
export interface ActionGridBlockData {
|
|
1010
|
+
items: ActionGridItem[];
|
|
1011
|
+
flash?: {
|
|
1012
|
+
success: boolean;
|
|
1013
|
+
message: string;
|
|
1014
|
+
} | null;
|
|
1015
|
+
}
|
|
1016
|
+
export interface ActionGridItem {
|
|
1017
|
+
id: string;
|
|
1018
|
+
label: Label;
|
|
1019
|
+
target: ActionTarget;
|
|
1020
|
+
intent: ActionIntent;
|
|
1021
|
+
icon?: string;
|
|
1022
|
+
confirmation?: Confirmation;
|
|
1023
|
+
capability?: string;
|
|
1024
|
+
disabled?: true;
|
|
1025
|
+
loading?: true;
|
|
1026
|
+
title: string;
|
|
1027
|
+
description: string;
|
|
1028
|
+
}
|
|
723
1029
|
|
|
@@ -167,6 +167,7 @@
|
|
|
167
167
|
"middag.ui.form.multiselect_selected": "{count} selected",
|
|
168
168
|
"middag.ui.form.no_fields": "No fields configured for this form.",
|
|
169
169
|
"middag.ui.form.phone_placeholder": "Phone number",
|
|
170
|
+
"middag.ui.form.required_hint": "(required)",
|
|
170
171
|
"middag.ui.form.required_label": "Required",
|
|
171
172
|
"middag.ui.form.save": "Save",
|
|
172
173
|
"middag.ui.form.saving": "Saving...",
|
|
@@ -167,6 +167,7 @@
|
|
|
167
167
|
"middag.ui.form.multiselect_selected": "{count} selecionado(s)",
|
|
168
168
|
"middag.ui.form.no_fields": "Nenhum campo configurado para este formulário.",
|
|
169
169
|
"middag.ui.form.phone_placeholder": "Número de telefone",
|
|
170
|
+
"middag.ui.form.required_hint": "(obrigatório)",
|
|
170
171
|
"middag.ui.form.required_label": "Obrigatório",
|
|
171
172
|
"middag.ui.form.save": "Salvar",
|
|
172
173
|
"middag.ui.form.saving": "Salvando...",
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useSyncExternalStore } from "react";
|
|
2
|
+
|
|
3
|
+
const REDUCED_MOTION_QUERY = "(prefers-reduced-motion: reduce)";
|
|
4
|
+
|
|
5
|
+
/** The media query list, or null where matchMedia is unavailable (SSR, old jsdom). */
|
|
6
|
+
function mediaQuery(): MediaQueryList | null {
|
|
7
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return null;
|
|
8
|
+
return window.matchMedia(REDUCED_MOTION_QUERY);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function subscribe(callback: () => void): () => void {
|
|
12
|
+
const mql = mediaQuery();
|
|
13
|
+
if (!mql) return () => {};
|
|
14
|
+
mql.addEventListener("change", callback);
|
|
15
|
+
return () => mql.removeEventListener("change", callback);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function getSnapshot(): boolean {
|
|
19
|
+
return mediaQuery()?.matches ?? false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function getServerSnapshot(): boolean {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* True when the user asked the OS to reduce motion. CSS covers transitions and
|
|
28
|
+
* keyframe animations; JS-driven animation (canvas, Lottie) must check this.
|
|
29
|
+
*/
|
|
30
|
+
export function usePrefersReducedMotion(): boolean {
|
|
31
|
+
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
32
|
+
}
|
|
@@ -3,6 +3,11 @@ import { Slot } from "radix-ui";
|
|
|
3
3
|
|
|
4
4
|
import { cn } from "@/lib/utils";
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Solid variants pair a fill with its `*-foreground` token; `*-light` and
|
|
8
|
+
* `*-outline` variants use the `*-text` status tokens, which keep WCAG AA on
|
|
9
|
+
* the tints and the canvas in light and dark mode (scripts/check-contrast.mjs).
|
|
10
|
+
*/
|
|
6
11
|
const badgeVariants = cva(
|
|
7
12
|
"relative inline-flex shrink-0 items-center justify-center w-fit border border-transparent font-medium whitespace-nowrap outline-none transition-shadow focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-3",
|
|
8
13
|
{
|
|
@@ -11,22 +16,22 @@ const badgeVariants = cva(
|
|
|
11
16
|
default: "bg-primary text-primary-foreground",
|
|
12
17
|
outline: "border-border bg-transparent dark:bg-input/32",
|
|
13
18
|
secondary: "bg-secondary text-secondary-foreground",
|
|
14
|
-
info: "bg-info text-
|
|
15
|
-
success: "bg-success text-
|
|
16
|
-
warning: "bg-warning text-
|
|
17
|
-
destructive: "bg-destructive text-
|
|
19
|
+
info: "bg-info text-info-foreground",
|
|
20
|
+
success: "bg-success text-success-foreground",
|
|
21
|
+
warning: "bg-warning text-warning-foreground",
|
|
22
|
+
destructive: "bg-destructive text-destructive-foreground",
|
|
18
23
|
focus: "bg-focus text-focus-foreground",
|
|
19
24
|
invert: "bg-invert text-invert-foreground",
|
|
20
25
|
"primary-light":
|
|
21
|
-
"bg-primary/10 border-none text-primary
|
|
26
|
+
"bg-primary/10 border-none text-primary",
|
|
22
27
|
"warning-light":
|
|
23
|
-
"bg-warning/10 border-none text-warning-
|
|
28
|
+
"bg-warning/10 border-none text-warning-text dark:bg-warning/20",
|
|
24
29
|
"success-light":
|
|
25
|
-
"bg-success/10 border-none text-success-
|
|
30
|
+
"bg-success/10 border-none text-success-text dark:bg-success/20",
|
|
26
31
|
"info-light":
|
|
27
|
-
"bg-info/10 border-none text-info-
|
|
32
|
+
"bg-info/10 border-none text-info-text dark:bg-info/20",
|
|
28
33
|
"destructive-light":
|
|
29
|
-
"bg-destructive/10 border-none text-destructive-
|
|
34
|
+
"bg-destructive/10 border-none text-destructive-text dark:bg-destructive/20",
|
|
30
35
|
"invert-light":
|
|
31
36
|
"bg-invert/10 border-none text-foreground dark:bg-invert/20",
|
|
32
37
|
"focus-light":
|
|
@@ -34,15 +39,15 @@ const badgeVariants = cva(
|
|
|
34
39
|
"primary-outline":
|
|
35
40
|
"bg-background border-border text-primary dark:bg-input/30",
|
|
36
41
|
"warning-outline":
|
|
37
|
-
"bg-background border-border text-warning-
|
|
42
|
+
"bg-background border-border text-warning-text dark:bg-input/30",
|
|
38
43
|
"success-outline":
|
|
39
|
-
"bg-background border-border text-success-
|
|
44
|
+
"bg-background border-border text-success-text dark:bg-input/30",
|
|
40
45
|
"info-outline":
|
|
41
|
-
"bg-background border-border text-info-
|
|
46
|
+
"bg-background border-border text-info-text dark:bg-input/30",
|
|
42
47
|
"destructive-outline":
|
|
43
|
-
"bg-background border-border text-destructive-
|
|
48
|
+
"bg-background border-border text-destructive-text dark:bg-input/30",
|
|
44
49
|
"invert-outline":
|
|
45
|
-
"bg-background border-border text-invert
|
|
50
|
+
"bg-background border-border text-invert dark:bg-input/30",
|
|
46
51
|
"focus-outline":
|
|
47
52
|
"bg-background border-border text-focus-foreground dark:bg-input/30",
|
|
48
53
|
},
|
|
@@ -25,13 +25,29 @@ import {
|
|
|
25
25
|
TooltipTrigger,
|
|
26
26
|
} from "@/primitives/reui/tooltip";
|
|
27
27
|
|
|
28
|
-
const SIDEBAR_COOKIE_NAME = "
|
|
28
|
+
const SIDEBAR_COOKIE_NAME = "middag_sidebar_state";
|
|
29
29
|
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
30
30
|
const SIDEBAR_WIDTH = "16rem";
|
|
31
31
|
const SIDEBAR_WIDTH_MOBILE = "18rem";
|
|
32
32
|
const SIDEBAR_WIDTH_ICON = "3rem";
|
|
33
33
|
const SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
|
34
34
|
|
|
35
|
+
/** useLayoutEffect on the client, useEffect during server rendering. */
|
|
36
|
+
const useIsomorphicLayoutEffect =
|
|
37
|
+
typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
38
|
+
|
|
39
|
+
/** The open state saved in the sidebar cookie, or null when there is none. */
|
|
40
|
+
function readSidebarCookie(): boolean | null {
|
|
41
|
+
if (typeof document === "undefined") return null;
|
|
42
|
+
const entry = document.cookie
|
|
43
|
+
.split("; ")
|
|
44
|
+
.find((part) => part.startsWith(`${SIDEBAR_COOKIE_NAME}=`));
|
|
45
|
+
const value = entry?.slice(SIDEBAR_COOKIE_NAME.length + 1);
|
|
46
|
+
if (value === "true") return true;
|
|
47
|
+
if (value === "false") return false;
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
35
51
|
type SidebarContextProps = {
|
|
36
52
|
state: "expanded" | "collapsed";
|
|
37
53
|
open: boolean;
|
|
@@ -54,7 +70,7 @@ function useSidebar() {
|
|
|
54
70
|
}
|
|
55
71
|
|
|
56
72
|
function SidebarProvider({
|
|
57
|
-
defaultOpen
|
|
73
|
+
defaultOpen,
|
|
58
74
|
open: openProp,
|
|
59
75
|
onOpenChange: setOpenProp,
|
|
60
76
|
className,
|
|
@@ -71,7 +87,18 @@ function SidebarProvider({
|
|
|
71
87
|
|
|
72
88
|
// This is the internal state of the sidebar.
|
|
73
89
|
// We use openProp and setOpenProp for control from outside the component.
|
|
74
|
-
|
|
90
|
+
// An explicit defaultOpen wins. Without one, the cookie written by setOpen
|
|
91
|
+
// restores the last state across page loads. The first render always uses
|
|
92
|
+
// the server-safe default (open), so server and client markup match; the
|
|
93
|
+
// cookie is applied in a layout effect, on the client, before first paint.
|
|
94
|
+
const [_open, _setOpen] = React.useState(defaultOpen ?? true);
|
|
95
|
+
useIsomorphicLayoutEffect(() => {
|
|
96
|
+
if (defaultOpen !== undefined || openProp !== undefined) return;
|
|
97
|
+
const saved = readSidebarCookie();
|
|
98
|
+
if (saved !== null) _setOpen(saved);
|
|
99
|
+
// Mount only: the cookie seeds the initial state, later toggles own it.
|
|
100
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
101
|
+
}, []);
|
|
75
102
|
const open = openProp ?? _open;
|
|
76
103
|
const setOpen = React.useCallback(
|
|
77
104
|
(value: boolean | ((value: boolean) => boolean)) => {
|
package/src/theme.css
CHANGED
|
@@ -30,6 +30,10 @@
|
|
|
30
30
|
--color-warning-foreground: var(--warning-foreground);
|
|
31
31
|
--color-info: var(--info);
|
|
32
32
|
--color-info-foreground: var(--info-foreground);
|
|
33
|
+
--color-destructive-text: var(--destructive-text);
|
|
34
|
+
--color-success-text: var(--success-text);
|
|
35
|
+
--color-warning-text: var(--warning-text);
|
|
36
|
+
--color-info-text: var(--info-text);
|
|
33
37
|
--color-muted: var(--muted);
|
|
34
38
|
--color-muted-foreground: var(--muted-foreground);
|
|
35
39
|
--color-accent: var(--accent);
|
|
@@ -63,9 +67,11 @@
|
|
|
63
67
|
--font-sans: var(--font-sans);
|
|
64
68
|
--font-mono: var(--font-mono);
|
|
65
69
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
--radius-
|
|
69
|
-
--radius-
|
|
70
|
-
--radius-
|
|
70
|
+
/* Radius values live in tokens.css (the unlayered :root value is the one
|
|
71
|
+
that renders); the utilities only point at them. */
|
|
72
|
+
--radius-sm: var(--radius-sm);
|
|
73
|
+
--radius-md: var(--radius-md);
|
|
74
|
+
--radius-lg: var(--radius-lg);
|
|
75
|
+
--radius-xl: var(--radius-xl);
|
|
76
|
+
--radius-2xl: var(--radius-2xl);
|
|
71
77
|
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { DateSelector as e } from "../primitives/reui/date-selector.js";
|
|
2
|
-
import { useCallback as t } from "react";
|
|
3
|
-
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
-
//#region src/base/form/fields/DateRangeField.tsx
|
|
5
|
-
function r({ id: r, value: i, onChange: a, operator: o, required: s, error: c, helpTextId: l, errorId: u }) {
|
|
6
|
-
let d = [c ? u : void 0, l].filter(Boolean).join(" ") || void 0, f = t((e) => {
|
|
7
|
-
a(e);
|
|
8
|
-
}, [a]);
|
|
9
|
-
return /* @__PURE__ */ n("div", {
|
|
10
|
-
id: r,
|
|
11
|
-
"aria-required": s || void 0,
|
|
12
|
-
"aria-invalid": c ? !0 : void 0,
|
|
13
|
-
"aria-describedby": d,
|
|
14
|
-
children: /* @__PURE__ */ n(e, {
|
|
15
|
-
value: i,
|
|
16
|
-
onChange: f,
|
|
17
|
-
allowRange: !0,
|
|
18
|
-
defaultFilterType: o ?? "is",
|
|
19
|
-
presetMode: o || void 0,
|
|
20
|
-
showInput: !0
|
|
21
|
-
})
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
//#endregion
|
|
25
|
-
export { r as DateRangeField };
|