@wordpress/dataviews 14.0.0 → 14.1.1-next.v.202604091042.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/CHANGELOG.md +10 -0
- package/README.md +16 -5
- package/build/components/dataform-controls/array.cjs +2 -0
- package/build/components/dataform-controls/array.cjs.map +2 -2
- package/build/components/dataform-controls/checkbox.cjs +3 -1
- package/build/components/dataform-controls/checkbox.cjs.map +2 -2
- package/build/components/dataform-controls/color.cjs +8 -2
- package/build/components/dataform-controls/color.cjs.map +2 -2
- package/build/components/dataform-controls/date.cjs +20 -9
- package/build/components/dataform-controls/date.cjs.map +2 -2
- package/build/components/dataform-controls/datetime.cjs +5 -2
- package/build/components/dataform-controls/datetime.cjs.map +2 -2
- package/build/components/dataform-controls/password.cjs +4 -1
- package/build/components/dataform-controls/password.cjs.map +2 -2
- package/build/components/dataform-controls/radio.cjs +3 -1
- package/build/components/dataform-controls/radio.cjs.map +2 -2
- package/build/components/dataform-controls/select.cjs +3 -1
- package/build/components/dataform-controls/select.cjs.map +2 -2
- package/build/components/dataform-controls/textarea.cjs +2 -0
- package/build/components/dataform-controls/textarea.cjs.map +2 -2
- package/build/components/dataform-controls/toggle-group.cjs +3 -1
- package/build/components/dataform-controls/toggle-group.cjs.map +2 -2
- package/build/components/dataform-controls/toggle.cjs +3 -1
- package/build/components/dataform-controls/toggle.cjs.map +2 -2
- package/build/components/dataform-controls/utils/relative-date-control.cjs +5 -2
- package/build/components/dataform-controls/utils/relative-date-control.cjs.map +2 -2
- package/build/components/dataform-controls/utils/validated-input.cjs +2 -0
- package/build/components/dataform-controls/utils/validated-input.cjs.map +2 -2
- package/build/components/dataform-controls/utils/validated-number.cjs +3 -1
- package/build/components/dataform-controls/utils/validated-number.cjs.map +2 -2
- package/build/components/dataviews-filters/input-widget.cjs +4 -0
- package/build/components/dataviews-filters/input-widget.cjs.map +2 -2
- package/build/components/dataviews-pagination/index.cjs +1 -0
- package/build/components/dataviews-pagination/index.cjs.map +2 -2
- package/build/field-types/index.cjs +1 -0
- package/build/field-types/index.cjs.map +2 -2
- package/build/types/field-api.cjs.map +1 -1
- package/build-module/components/dataform-controls/array.mjs +2 -0
- package/build-module/components/dataform-controls/array.mjs.map +2 -2
- package/build-module/components/dataform-controls/checkbox.mjs +3 -1
- package/build-module/components/dataform-controls/checkbox.mjs.map +2 -2
- package/build-module/components/dataform-controls/color.mjs +8 -2
- package/build-module/components/dataform-controls/color.mjs.map +2 -2
- package/build-module/components/dataform-controls/date.mjs +20 -9
- package/build-module/components/dataform-controls/date.mjs.map +2 -2
- package/build-module/components/dataform-controls/datetime.mjs +5 -2
- package/build-module/components/dataform-controls/datetime.mjs.map +2 -2
- package/build-module/components/dataform-controls/password.mjs +4 -1
- package/build-module/components/dataform-controls/password.mjs.map +2 -2
- package/build-module/components/dataform-controls/radio.mjs +3 -1
- package/build-module/components/dataform-controls/radio.mjs.map +2 -2
- package/build-module/components/dataform-controls/select.mjs +3 -1
- package/build-module/components/dataform-controls/select.mjs.map +2 -2
- package/build-module/components/dataform-controls/textarea.mjs +2 -0
- package/build-module/components/dataform-controls/textarea.mjs.map +2 -2
- package/build-module/components/dataform-controls/toggle-group.mjs +3 -1
- package/build-module/components/dataform-controls/toggle-group.mjs.map +2 -2
- package/build-module/components/dataform-controls/toggle.mjs +3 -1
- package/build-module/components/dataform-controls/toggle.mjs.map +2 -2
- package/build-module/components/dataform-controls/utils/relative-date-control.mjs +5 -2
- package/build-module/components/dataform-controls/utils/relative-date-control.mjs.map +2 -2
- package/build-module/components/dataform-controls/utils/validated-input.mjs +2 -0
- package/build-module/components/dataform-controls/utils/validated-input.mjs.map +2 -2
- package/build-module/components/dataform-controls/utils/validated-number.mjs +3 -1
- package/build-module/components/dataform-controls/utils/validated-number.mjs.map +2 -2
- package/build-module/components/dataviews-filters/input-widget.mjs +4 -0
- package/build-module/components/dataviews-filters/input-widget.mjs.map +2 -2
- package/build-module/components/dataviews-pagination/index.mjs +1 -0
- package/build-module/components/dataviews-pagination/index.mjs.map +2 -2
- package/build-module/field-types/index.mjs +1 -0
- package/build-module/field-types/index.mjs.map +2 -2
- package/build-style/style-rtl.css +2 -2
- package/build-style/style.css +2 -2
- package/build-types/components/dataform-controls/array.d.ts.map +1 -1
- package/build-types/components/dataform-controls/checkbox.d.ts.map +1 -1
- package/build-types/components/dataform-controls/color.d.ts.map +1 -1
- package/build-types/components/dataform-controls/date.d.ts.map +1 -1
- package/build-types/components/dataform-controls/datetime.d.ts.map +1 -1
- package/build-types/components/dataform-controls/password.d.ts.map +1 -1
- package/build-types/components/dataform-controls/radio.d.ts.map +1 -1
- package/build-types/components/dataform-controls/select.d.ts.map +1 -1
- package/build-types/components/dataform-controls/textarea.d.ts.map +1 -1
- package/build-types/components/dataform-controls/toggle-group.d.ts.map +1 -1
- package/build-types/components/dataform-controls/toggle.d.ts.map +1 -1
- package/build-types/components/dataform-controls/utils/relative-date-control.d.ts.map +1 -1
- package/build-types/components/dataform-controls/utils/validated-input.d.ts.map +1 -1
- package/build-types/components/dataform-controls/utils/validated-number.d.ts.map +1 -1
- package/build-types/components/dataviews-filters/input-widget.d.ts.map +1 -1
- package/build-types/components/dataviews-layouts/index.d.ts +6 -6
- package/build-types/components/dataviews-pagination/index.d.ts.map +1 -1
- package/build-types/components/dataviews-search/index.d.ts +1 -1
- package/build-types/components/dataviews-search/index.d.ts.map +1 -1
- package/build-types/constants.d.ts +2 -2
- package/build-types/dataform/stories/index.story.d.ts +11 -1
- package/build-types/dataform/stories/index.story.d.ts.map +1 -1
- package/build-types/dataform/stories/layout-regular.d.ts +2 -1
- package/build-types/dataform/stories/layout-regular.d.ts.map +1 -1
- package/build-types/field-types/array.d.ts +1 -1
- package/build-types/field-types/array.d.ts.map +1 -1
- package/build-types/field-types/boolean.d.ts +1 -1
- package/build-types/field-types/boolean.d.ts.map +1 -1
- package/build-types/field-types/color.d.ts +1 -1
- package/build-types/field-types/color.d.ts.map +1 -1
- package/build-types/field-types/email.d.ts +1 -1
- package/build-types/field-types/email.d.ts.map +1 -1
- package/build-types/field-types/index.d.ts.map +1 -1
- package/build-types/field-types/integer.d.ts +1 -1
- package/build-types/field-types/integer.d.ts.map +1 -1
- package/build-types/field-types/number.d.ts +1 -1
- package/build-types/field-types/number.d.ts.map +1 -1
- package/build-types/field-types/stories/index.story.d.ts +37 -15
- package/build-types/field-types/stories/index.story.d.ts.map +1 -1
- package/build-types/types/field-api.d.ts +13 -0
- package/build-types/types/field-api.d.ts.map +1 -1
- package/build-wp/index.js +124 -56
- package/package.json +16 -16
- package/src/components/dataform-controls/array.tsx +2 -0
- package/src/components/dataform-controls/checkbox.tsx +2 -0
- package/src/components/dataform-controls/color.tsx +7 -0
- package/src/components/dataform-controls/date.tsx +15 -4
- package/src/components/dataform-controls/datetime.tsx +3 -0
- package/src/components/dataform-controls/password.tsx +3 -0
- package/src/components/dataform-controls/radio.tsx +2 -0
- package/src/components/dataform-controls/select.tsx +2 -0
- package/src/components/dataform-controls/textarea.tsx +2 -0
- package/src/components/dataform-controls/toggle-group.tsx +2 -0
- package/src/components/dataform-controls/toggle.tsx +2 -0
- package/src/components/dataform-controls/utils/relative-date-control.tsx +3 -0
- package/src/components/dataform-controls/utils/validated-input.tsx +2 -0
- package/src/components/dataform-controls/utils/validated-number.tsx +2 -0
- package/src/components/dataviews-filters/input-widget.tsx +4 -0
- package/src/components/dataviews-layouts/activity/style.scss +2 -2
- package/src/components/dataviews-pagination/index.tsx +1 -0
- package/src/dataform/stories/index.story.tsx +7 -0
- package/src/dataform/stories/layout-regular.tsx +15 -1
- package/src/field-types/index.tsx +4 -0
- package/src/field-types/stories/index.story.tsx +66 -5
- package/src/types/field-api.ts +16 -0
|
@@ -66,12 +66,17 @@ const meta = {
|
|
|
66
66
|
'Add 10 more elements to push over the threshold and trigger Combobox rendering',
|
|
67
67
|
if: { arg: 'Edit', eq: 'adaptiveSelect' },
|
|
68
68
|
},
|
|
69
|
+
disabled: {
|
|
70
|
+
control: { type: 'boolean' },
|
|
71
|
+
description: 'Whether the field controls are disabled.',
|
|
72
|
+
},
|
|
69
73
|
},
|
|
70
74
|
args: {
|
|
71
75
|
type: 'regular',
|
|
72
76
|
Edit: 'default',
|
|
73
77
|
asyncElements: false,
|
|
74
78
|
manyElements: false,
|
|
79
|
+
disabled: false,
|
|
75
80
|
},
|
|
76
81
|
};
|
|
77
82
|
export default meta;
|
|
@@ -590,6 +595,7 @@ interface FieldTypeStoryProps {
|
|
|
590
595
|
Edit: ControlTypes;
|
|
591
596
|
asyncElements: boolean;
|
|
592
597
|
manyElements: boolean;
|
|
598
|
+
disabled: boolean;
|
|
593
599
|
}
|
|
594
600
|
|
|
595
601
|
const FieldTypeStory = ( {
|
|
@@ -598,17 +604,27 @@ const FieldTypeStory = ( {
|
|
|
598
604
|
Edit,
|
|
599
605
|
asyncElements,
|
|
600
606
|
manyElements,
|
|
607
|
+
disabled,
|
|
601
608
|
}: FieldTypeStoryProps ) => {
|
|
602
609
|
const storyFields = useMemo( () => {
|
|
603
610
|
let fieldsToProcess = _fields;
|
|
604
611
|
|
|
605
|
-
if (
|
|
606
|
-
fieldsToProcess =
|
|
612
|
+
if ( disabled ) {
|
|
613
|
+
fieldsToProcess = fieldsToProcess.map( ( field ) => ( {
|
|
607
614
|
...field,
|
|
608
|
-
|
|
615
|
+
isDisabled: true,
|
|
609
616
|
} ) );
|
|
610
617
|
}
|
|
611
618
|
|
|
619
|
+
if ( Edit !== 'default' ) {
|
|
620
|
+
fieldsToProcess = fieldsToProcess.map(
|
|
621
|
+
( field: Field< DataType > ) => ( {
|
|
622
|
+
...field,
|
|
623
|
+
Edit,
|
|
624
|
+
} )
|
|
625
|
+
);
|
|
626
|
+
}
|
|
627
|
+
|
|
612
628
|
// Expand elements when adaptiveSelect is selected and manyElements is toggled
|
|
613
629
|
if ( Edit === 'adaptiveSelect' && manyElements ) {
|
|
614
630
|
fieldsToProcess = fieldsToProcess.map( ( field ) => {
|
|
@@ -648,7 +664,7 @@ const FieldTypeStory = ( {
|
|
|
648
664
|
}
|
|
649
665
|
|
|
650
666
|
return fieldsToProcess;
|
|
651
|
-
}, [ _fields, Edit, asyncElements, manyElements ] );
|
|
667
|
+
}, [ _fields, Edit, asyncElements, manyElements, disabled ] );
|
|
652
668
|
const form = useMemo(
|
|
653
669
|
() => ( {
|
|
654
670
|
layout: { type },
|
|
@@ -756,11 +772,13 @@ export const AllComponent = ( {
|
|
|
756
772
|
Edit,
|
|
757
773
|
asyncElements,
|
|
758
774
|
manyElements,
|
|
775
|
+
disabled,
|
|
759
776
|
}: {
|
|
760
777
|
type: PanelTypes;
|
|
761
778
|
Edit: ControlTypes;
|
|
762
779
|
asyncElements: boolean;
|
|
763
780
|
manyElements: boolean;
|
|
781
|
+
disabled: boolean;
|
|
764
782
|
} ) => {
|
|
765
783
|
return (
|
|
766
784
|
<FieldTypeStory
|
|
@@ -769,6 +787,7 @@ export const AllComponent = ( {
|
|
|
769
787
|
Edit={ Edit }
|
|
770
788
|
asyncElements={ asyncElements }
|
|
771
789
|
manyElements={ manyElements }
|
|
790
|
+
disabled={ disabled }
|
|
772
791
|
/>
|
|
773
792
|
);
|
|
774
793
|
};
|
|
@@ -779,11 +798,13 @@ export const TextComponent = ( {
|
|
|
779
798
|
Edit,
|
|
780
799
|
asyncElements,
|
|
781
800
|
manyElements,
|
|
801
|
+
disabled,
|
|
782
802
|
}: {
|
|
783
803
|
type: PanelTypes;
|
|
784
804
|
Edit: ControlTypes;
|
|
785
805
|
asyncElements: boolean;
|
|
786
806
|
manyElements: boolean;
|
|
807
|
+
disabled: boolean;
|
|
787
808
|
} ) => {
|
|
788
809
|
const textFields = useMemo(
|
|
789
810
|
() => fields.filter( ( field ) => field.type === 'text' ),
|
|
@@ -797,6 +818,7 @@ export const TextComponent = ( {
|
|
|
797
818
|
Edit={ Edit }
|
|
798
819
|
asyncElements={ asyncElements }
|
|
799
820
|
manyElements={ manyElements }
|
|
821
|
+
disabled={ disabled }
|
|
800
822
|
/>
|
|
801
823
|
);
|
|
802
824
|
};
|
|
@@ -808,12 +830,14 @@ export const IntegerComponent = ( {
|
|
|
808
830
|
asyncElements,
|
|
809
831
|
manyElements,
|
|
810
832
|
formatSeparatorThousand,
|
|
833
|
+
disabled,
|
|
811
834
|
}: {
|
|
812
835
|
type: PanelTypes;
|
|
813
836
|
Edit: ControlTypes;
|
|
814
837
|
asyncElements: boolean;
|
|
815
838
|
manyElements: boolean;
|
|
816
839
|
formatSeparatorThousand?: string;
|
|
840
|
+
disabled: boolean;
|
|
817
841
|
} ) => {
|
|
818
842
|
const integerFields = useMemo(
|
|
819
843
|
() =>
|
|
@@ -840,6 +864,7 @@ export const IntegerComponent = ( {
|
|
|
840
864
|
Edit={ Edit }
|
|
841
865
|
asyncElements={ asyncElements }
|
|
842
866
|
manyElements={ manyElements }
|
|
867
|
+
disabled={ disabled }
|
|
843
868
|
/>
|
|
844
869
|
);
|
|
845
870
|
};
|
|
@@ -863,6 +888,7 @@ export const NumberComponent = ( {
|
|
|
863
888
|
formatSeparatorThousand,
|
|
864
889
|
formatSeparatorDecimal,
|
|
865
890
|
formatDecimals,
|
|
891
|
+
disabled,
|
|
866
892
|
}: {
|
|
867
893
|
type: PanelTypes;
|
|
868
894
|
Edit: ControlTypes;
|
|
@@ -871,6 +897,7 @@ export const NumberComponent = ( {
|
|
|
871
897
|
formatSeparatorThousand?: string;
|
|
872
898
|
formatSeparatorDecimal?: string;
|
|
873
899
|
formatDecimals?: number;
|
|
900
|
+
disabled: boolean;
|
|
874
901
|
} ) => {
|
|
875
902
|
const numberFields = useMemo(
|
|
876
903
|
() =>
|
|
@@ -913,6 +940,7 @@ export const NumberComponent = ( {
|
|
|
913
940
|
Edit={ Edit }
|
|
914
941
|
asyncElements={ asyncElements }
|
|
915
942
|
manyElements={ manyElements }
|
|
943
|
+
disabled={ disabled }
|
|
916
944
|
/>
|
|
917
945
|
);
|
|
918
946
|
};
|
|
@@ -945,11 +973,13 @@ export const BooleanComponent = ( {
|
|
|
945
973
|
Edit,
|
|
946
974
|
asyncElements,
|
|
947
975
|
manyElements,
|
|
976
|
+
disabled,
|
|
948
977
|
}: {
|
|
949
978
|
type: PanelTypes;
|
|
950
979
|
Edit: ControlTypes;
|
|
951
980
|
asyncElements: boolean;
|
|
952
981
|
manyElements: boolean;
|
|
982
|
+
disabled: boolean;
|
|
953
983
|
} ) => {
|
|
954
984
|
const booleanFields = useMemo(
|
|
955
985
|
() => fields.filter( ( field ) => field.type === 'boolean' ),
|
|
@@ -963,6 +993,7 @@ export const BooleanComponent = ( {
|
|
|
963
993
|
Edit={ Edit }
|
|
964
994
|
asyncElements={ asyncElements }
|
|
965
995
|
manyElements={ manyElements }
|
|
996
|
+
disabled={ disabled }
|
|
966
997
|
/>
|
|
967
998
|
);
|
|
968
999
|
};
|
|
@@ -975,6 +1006,7 @@ export const DateTimeComponent = ( {
|
|
|
975
1006
|
manyElements,
|
|
976
1007
|
formatDatetime,
|
|
977
1008
|
formatWeekStartsOn,
|
|
1009
|
+
disabled,
|
|
978
1010
|
}: {
|
|
979
1011
|
type: PanelTypes;
|
|
980
1012
|
Edit: ControlTypes;
|
|
@@ -982,6 +1014,7 @@ export const DateTimeComponent = ( {
|
|
|
982
1014
|
manyElements: boolean;
|
|
983
1015
|
formatDatetime?: string;
|
|
984
1016
|
formatWeekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
1017
|
+
disabled: boolean;
|
|
985
1018
|
} ) => {
|
|
986
1019
|
const datetimeFields = useMemo(
|
|
987
1020
|
() =>
|
|
@@ -1006,7 +1039,7 @@ export const DateTimeComponent = ( {
|
|
|
1006
1039
|
}
|
|
1007
1040
|
return field;
|
|
1008
1041
|
} ),
|
|
1009
|
-
[
|
|
1042
|
+
[ formatDatetime, formatWeekStartsOn ]
|
|
1010
1043
|
);
|
|
1011
1044
|
|
|
1012
1045
|
return (
|
|
@@ -1016,6 +1049,7 @@ export const DateTimeComponent = ( {
|
|
|
1016
1049
|
Edit={ Edit }
|
|
1017
1050
|
asyncElements={ asyncElements }
|
|
1018
1051
|
manyElements={ manyElements }
|
|
1052
|
+
disabled={ disabled }
|
|
1019
1053
|
/>
|
|
1020
1054
|
);
|
|
1021
1055
|
};
|
|
@@ -1054,6 +1088,7 @@ export const DateComponent = ( {
|
|
|
1054
1088
|
manyElements,
|
|
1055
1089
|
formatDate,
|
|
1056
1090
|
formatWeekStartsOn,
|
|
1091
|
+
disabled,
|
|
1057
1092
|
}: {
|
|
1058
1093
|
type: PanelTypes;
|
|
1059
1094
|
Edit: ControlTypes;
|
|
@@ -1061,6 +1096,7 @@ export const DateComponent = ( {
|
|
|
1061
1096
|
manyElements: boolean;
|
|
1062
1097
|
formatDate?: string;
|
|
1063
1098
|
formatWeekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
1099
|
+
disabled: boolean;
|
|
1064
1100
|
} ) => {
|
|
1065
1101
|
const dateFields = useMemo(
|
|
1066
1102
|
() =>
|
|
@@ -1095,6 +1131,7 @@ export const DateComponent = ( {
|
|
|
1095
1131
|
Edit={ Edit }
|
|
1096
1132
|
asyncElements={ asyncElements }
|
|
1097
1133
|
manyElements={ manyElements }
|
|
1134
|
+
disabled={ disabled }
|
|
1098
1135
|
/>
|
|
1099
1136
|
);
|
|
1100
1137
|
};
|
|
@@ -1131,11 +1168,13 @@ export const EmailComponent = ( {
|
|
|
1131
1168
|
Edit,
|
|
1132
1169
|
asyncElements,
|
|
1133
1170
|
manyElements,
|
|
1171
|
+
disabled,
|
|
1134
1172
|
}: {
|
|
1135
1173
|
type: PanelTypes;
|
|
1136
1174
|
Edit: ControlTypes;
|
|
1137
1175
|
asyncElements: boolean;
|
|
1138
1176
|
manyElements: boolean;
|
|
1177
|
+
disabled: boolean;
|
|
1139
1178
|
} ) => {
|
|
1140
1179
|
const emailFields = useMemo(
|
|
1141
1180
|
() => fields.filter( ( field ) => field.type === 'email' ),
|
|
@@ -1149,6 +1188,7 @@ export const EmailComponent = ( {
|
|
|
1149
1188
|
Edit={ Edit }
|
|
1150
1189
|
asyncElements={ asyncElements }
|
|
1151
1190
|
manyElements={ manyElements }
|
|
1191
|
+
disabled={ disabled }
|
|
1152
1192
|
/>
|
|
1153
1193
|
);
|
|
1154
1194
|
};
|
|
@@ -1159,11 +1199,13 @@ export const TelephoneComponent = ( {
|
|
|
1159
1199
|
Edit,
|
|
1160
1200
|
asyncElements,
|
|
1161
1201
|
manyElements,
|
|
1202
|
+
disabled,
|
|
1162
1203
|
}: {
|
|
1163
1204
|
type: PanelTypes;
|
|
1164
1205
|
Edit: ControlTypes;
|
|
1165
1206
|
asyncElements: boolean;
|
|
1166
1207
|
manyElements: boolean;
|
|
1208
|
+
disabled: boolean;
|
|
1167
1209
|
} ) => {
|
|
1168
1210
|
const telephoneFields = fields.filter( ( field ) =>
|
|
1169
1211
|
field.id.startsWith( 'telephone' )
|
|
@@ -1176,6 +1218,7 @@ export const TelephoneComponent = ( {
|
|
|
1176
1218
|
Edit={ Edit }
|
|
1177
1219
|
asyncElements={ asyncElements }
|
|
1178
1220
|
manyElements={ manyElements }
|
|
1221
|
+
disabled={ disabled }
|
|
1179
1222
|
/>
|
|
1180
1223
|
);
|
|
1181
1224
|
};
|
|
@@ -1186,11 +1229,13 @@ export const UrlComponent = ( {
|
|
|
1186
1229
|
Edit,
|
|
1187
1230
|
asyncElements,
|
|
1188
1231
|
manyElements,
|
|
1232
|
+
disabled,
|
|
1189
1233
|
}: {
|
|
1190
1234
|
type: PanelTypes;
|
|
1191
1235
|
Edit: ControlTypes;
|
|
1192
1236
|
asyncElements: boolean;
|
|
1193
1237
|
manyElements: boolean;
|
|
1238
|
+
disabled: boolean;
|
|
1194
1239
|
} ) => {
|
|
1195
1240
|
const urlFields = useMemo(
|
|
1196
1241
|
() => fields.filter( ( field ) => field.type === 'url' ),
|
|
@@ -1204,6 +1249,7 @@ export const UrlComponent = ( {
|
|
|
1204
1249
|
Edit={ Edit }
|
|
1205
1250
|
asyncElements={ asyncElements }
|
|
1206
1251
|
manyElements={ manyElements }
|
|
1252
|
+
disabled={ disabled }
|
|
1207
1253
|
/>
|
|
1208
1254
|
);
|
|
1209
1255
|
};
|
|
@@ -1214,11 +1260,13 @@ export const ColorComponent = ( {
|
|
|
1214
1260
|
Edit,
|
|
1215
1261
|
asyncElements,
|
|
1216
1262
|
manyElements,
|
|
1263
|
+
disabled,
|
|
1217
1264
|
}: {
|
|
1218
1265
|
type: PanelTypes;
|
|
1219
1266
|
Edit: ControlTypes;
|
|
1220
1267
|
asyncElements: boolean;
|
|
1221
1268
|
manyElements: boolean;
|
|
1269
|
+
disabled: boolean;
|
|
1222
1270
|
} ) => {
|
|
1223
1271
|
const colorFields = useMemo(
|
|
1224
1272
|
() => fields.filter( ( field ) => field.type === 'color' ),
|
|
@@ -1232,6 +1280,7 @@ export const ColorComponent = ( {
|
|
|
1232
1280
|
Edit={ Edit }
|
|
1233
1281
|
asyncElements={ asyncElements }
|
|
1234
1282
|
manyElements={ manyElements }
|
|
1283
|
+
disabled={ disabled }
|
|
1235
1284
|
/>
|
|
1236
1285
|
);
|
|
1237
1286
|
};
|
|
@@ -1242,11 +1291,13 @@ export const MediaComponent = ( {
|
|
|
1242
1291
|
Edit,
|
|
1243
1292
|
asyncElements,
|
|
1244
1293
|
manyElements,
|
|
1294
|
+
disabled,
|
|
1245
1295
|
}: {
|
|
1246
1296
|
type: PanelTypes;
|
|
1247
1297
|
Edit: ControlTypes;
|
|
1248
1298
|
asyncElements: boolean;
|
|
1249
1299
|
manyElements: boolean;
|
|
1300
|
+
disabled: boolean;
|
|
1250
1301
|
} ) => {
|
|
1251
1302
|
const mediaFields = useMemo(
|
|
1252
1303
|
() => fields.filter( ( field ) => field.type === 'media' ),
|
|
@@ -1260,6 +1311,7 @@ export const MediaComponent = ( {
|
|
|
1260
1311
|
Edit={ Edit }
|
|
1261
1312
|
asyncElements={ asyncElements }
|
|
1262
1313
|
manyElements={ manyElements }
|
|
1314
|
+
disabled={ disabled }
|
|
1263
1315
|
/>
|
|
1264
1316
|
);
|
|
1265
1317
|
};
|
|
@@ -1270,11 +1322,13 @@ export const ArrayComponent = ( {
|
|
|
1270
1322
|
Edit,
|
|
1271
1323
|
asyncElements,
|
|
1272
1324
|
manyElements,
|
|
1325
|
+
disabled,
|
|
1273
1326
|
}: {
|
|
1274
1327
|
type: PanelTypes;
|
|
1275
1328
|
Edit: ControlTypes;
|
|
1276
1329
|
asyncElements: boolean;
|
|
1277
1330
|
manyElements: boolean;
|
|
1331
|
+
disabled: boolean;
|
|
1278
1332
|
} ) => {
|
|
1279
1333
|
const arrayTextFields = useMemo(
|
|
1280
1334
|
() => fields.filter( ( field ) => field.type === 'array' ),
|
|
@@ -1288,6 +1342,7 @@ export const ArrayComponent = ( {
|
|
|
1288
1342
|
Edit={ Edit }
|
|
1289
1343
|
asyncElements={ asyncElements }
|
|
1290
1344
|
manyElements={ manyElements }
|
|
1345
|
+
disabled={ disabled }
|
|
1291
1346
|
/>
|
|
1292
1347
|
);
|
|
1293
1348
|
};
|
|
@@ -1298,11 +1353,13 @@ export const PasswordComponent = ( {
|
|
|
1298
1353
|
Edit,
|
|
1299
1354
|
asyncElements,
|
|
1300
1355
|
manyElements,
|
|
1356
|
+
disabled,
|
|
1301
1357
|
}: {
|
|
1302
1358
|
type: PanelTypes;
|
|
1303
1359
|
Edit: ControlTypes;
|
|
1304
1360
|
asyncElements: boolean;
|
|
1305
1361
|
manyElements: boolean;
|
|
1362
|
+
disabled: boolean;
|
|
1306
1363
|
} ) => {
|
|
1307
1364
|
const passwordFields = fields.filter( ( field ) =>
|
|
1308
1365
|
field.id.startsWith( 'password' )
|
|
@@ -1315,6 +1372,7 @@ export const PasswordComponent = ( {
|
|
|
1315
1372
|
Edit={ Edit }
|
|
1316
1373
|
asyncElements={ asyncElements }
|
|
1317
1374
|
manyElements={ manyElements }
|
|
1375
|
+
disabled={ disabled }
|
|
1318
1376
|
/>
|
|
1319
1377
|
);
|
|
1320
1378
|
};
|
|
@@ -1325,11 +1383,13 @@ export const NoTypeComponent = ( {
|
|
|
1325
1383
|
Edit,
|
|
1326
1384
|
asyncElements,
|
|
1327
1385
|
manyElements,
|
|
1386
|
+
disabled,
|
|
1328
1387
|
}: {
|
|
1329
1388
|
type: PanelTypes;
|
|
1330
1389
|
Edit: ControlTypes;
|
|
1331
1390
|
asyncElements: boolean;
|
|
1332
1391
|
manyElements: boolean;
|
|
1392
|
+
disabled: boolean;
|
|
1333
1393
|
} ) => {
|
|
1334
1394
|
const noTypeFields = useMemo(
|
|
1335
1395
|
() => fields.filter( ( field ) => field.type === undefined ),
|
|
@@ -1343,6 +1403,7 @@ export const NoTypeComponent = ( {
|
|
|
1343
1403
|
Edit={ Edit }
|
|
1344
1404
|
asyncElements={ asyncElements }
|
|
1345
1405
|
manyElements={ manyElements }
|
|
1406
|
+
disabled={ disabled }
|
|
1346
1407
|
/>
|
|
1347
1408
|
);
|
|
1348
1409
|
};
|
package/src/types/field-api.ts
CHANGED
|
@@ -244,6 +244,18 @@ export type Field< Item > = {
|
|
|
244
244
|
*/
|
|
245
245
|
isVisible?: ( item: Item ) => boolean;
|
|
246
246
|
|
|
247
|
+
/**
|
|
248
|
+
* Whether a field should be disabled.
|
|
249
|
+
* Can be a boolean or a callback receiving the current item and field.
|
|
250
|
+
* Defaults to false.
|
|
251
|
+
*/
|
|
252
|
+
isDisabled?:
|
|
253
|
+
| boolean
|
|
254
|
+
| ( ( args: {
|
|
255
|
+
item: Item;
|
|
256
|
+
field: NormalizedField< Item >;
|
|
257
|
+
} ) => boolean );
|
|
258
|
+
|
|
247
259
|
/**
|
|
248
260
|
* Whether the field is sortable.
|
|
249
261
|
*/
|
|
@@ -380,6 +392,10 @@ export type NormalizedField< Item > = Omit<
|
|
|
380
392
|
filterBy: Required< FilterByConfig > | false;
|
|
381
393
|
filter: FilterOperatorMap< Item >;
|
|
382
394
|
readOnly: boolean;
|
|
395
|
+
isDisabled: ( args: {
|
|
396
|
+
item: Item;
|
|
397
|
+
field: NormalizedField< Item >;
|
|
398
|
+
} ) => boolean;
|
|
383
399
|
format:
|
|
384
400
|
| {}
|
|
385
401
|
| Required< FormatDate >
|