@uniform-ts/core 0.0.5 → 0.0.7
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/README.md +14 -14
- package/dist/field-DPgaGkOL.d.mts +730 -0
- package/dist/field-DPgaGkOL.d.ts +730 -0
- package/dist/index.d.mts +8 -717
- package/dist/index.d.ts +8 -717
- package/dist/index.js +21 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -12
- package/dist/index.mjs.map +1 -1
- package/dist/locales/en.d.mts +8 -0
- package/dist/locales/en.d.ts +8 -0
- package/dist/locales/en.js +24 -0
- package/dist/locales/en.js.map +1 -0
- package/dist/locales/en.mjs +22 -0
- package/dist/locales/en.mjs.map +1 -0
- package/dist/locales/es.d.mts +8 -0
- package/dist/locales/es.d.ts +8 -0
- package/dist/locales/es.js +24 -0
- package/dist/locales/es.js.map +1 -0
- package/dist/locales/es.mjs +22 -0
- package/dist/locales/es.mjs.map +1 -0
- package/dist/locales/he.d.mts +8 -0
- package/dist/locales/he.d.ts +8 -0
- package/dist/locales/he.js +24 -0
- package/dist/locales/he.js.map +1 -0
- package/dist/locales/he.mjs +22 -0
- package/dist/locales/he.mjs.map +1 -0
- package/package.json +20 -6
package/dist/index.js
CHANGED
|
@@ -720,7 +720,7 @@ function getDefaultValue(field) {
|
|
|
720
720
|
return void 0;
|
|
721
721
|
}
|
|
722
722
|
}
|
|
723
|
-
function getRowSummary(row, itemConfig, index) {
|
|
723
|
+
function getRowSummary(row, itemConfig, index, itemSummary) {
|
|
724
724
|
if (itemConfig.type === "object") {
|
|
725
725
|
for (const child of itemConfig.children) {
|
|
726
726
|
const key = child.name.split(".").pop() ?? child.name;
|
|
@@ -730,7 +730,7 @@ function getRowSummary(row, itemConfig, index) {
|
|
|
730
730
|
}
|
|
731
731
|
}
|
|
732
732
|
}
|
|
733
|
-
return `Item ${index + 1}`;
|
|
733
|
+
return itemSummary?.(index) ?? `Item ${index + 1}`;
|
|
734
734
|
}
|
|
735
735
|
function ArrayField({ field, control, effectiveName }) {
|
|
736
736
|
const { classNames, layout, labels } = useAutoFormContext();
|
|
@@ -787,7 +787,7 @@ function ArrayField({ field, control, effectiveName }) {
|
|
|
787
787
|
type: "button",
|
|
788
788
|
className: classNames.arrayCollapse,
|
|
789
789
|
onClick: () => toggleCollapse(index),
|
|
790
|
-
"aria-label": isCollapsed ? `Expand item ${index + 1}` : `Collapse item ${index + 1}`,
|
|
790
|
+
"aria-label": isCollapsed ? labels.arrayAriaExpand?.(index) ?? `Expand item ${index + 1}` : labels.arrayAriaCollapse?.(index) ?? `Collapse item ${index + 1}`,
|
|
791
791
|
isCollapsed,
|
|
792
792
|
children: [
|
|
793
793
|
isCollapsed ? labels.arrayExpand ?? "\u25BC" : labels.arrayCollapse ?? "\u25B6",
|
|
@@ -812,7 +812,7 @@ function ArrayField({ field, control, effectiveName }) {
|
|
|
812
812
|
className: classNames.arrayMove,
|
|
813
813
|
onClick: () => move(index, index - 1),
|
|
814
814
|
disabled: index === 0,
|
|
815
|
-
"aria-label": `Move item ${index + 1} up`,
|
|
815
|
+
"aria-label": labels.arrayAriaMoveUp?.(index) ?? `Move item ${index + 1} up`,
|
|
816
816
|
children: labels.arrayMoveUp ?? "\u2191"
|
|
817
817
|
}
|
|
818
818
|
) : null;
|
|
@@ -823,7 +823,7 @@ function ArrayField({ field, control, effectiveName }) {
|
|
|
823
823
|
className: classNames.arrayMove,
|
|
824
824
|
onClick: () => move(index, index + 1),
|
|
825
825
|
disabled: index === rows.length - 1,
|
|
826
|
-
"aria-label": `Move item ${index + 1} down`,
|
|
826
|
+
"aria-label": labels.arrayAriaMoveDown?.(index) ?? `Move item ${index + 1} down`,
|
|
827
827
|
children: labels.arrayMoveDown ?? "\u2193"
|
|
828
828
|
}
|
|
829
829
|
) : null;
|
|
@@ -838,7 +838,7 @@ function ArrayField({ field, control, effectiveName }) {
|
|
|
838
838
|
);
|
|
839
839
|
insert(index + 1, values);
|
|
840
840
|
},
|
|
841
|
-
"aria-label": `Duplicate item ${index + 1}`,
|
|
841
|
+
"aria-label": labels.arrayAriaDuplicate?.(index) ?? `Duplicate item ${index + 1}`,
|
|
842
842
|
children: labels.arrayDuplicate ?? "Duplicate"
|
|
843
843
|
}
|
|
844
844
|
) : null;
|
|
@@ -849,7 +849,7 @@ function ArrayField({ field, control, effectiveName }) {
|
|
|
849
849
|
className: classNames.arrayRemove,
|
|
850
850
|
onClick: () => remove(index),
|
|
851
851
|
disabled: atMin,
|
|
852
|
-
"aria-label": `Remove item ${index + 1}`,
|
|
852
|
+
"aria-label": labels.arrayAriaRemove?.(index) ?? `Remove item ${index + 1}`,
|
|
853
853
|
children: labels.arrayRemove ?? "Remove"
|
|
854
854
|
}
|
|
855
855
|
);
|
|
@@ -918,13 +918,22 @@ function CollapseSummary({
|
|
|
918
918
|
itemConfig,
|
|
919
919
|
isCollapsed
|
|
920
920
|
}) {
|
|
921
|
+
const { labels } = useAutoFormContext();
|
|
922
|
+
const fallback = labels.arrayItemSummary?.(index) ?? `Item ${index + 1}`;
|
|
921
923
|
const rowValues = reactHookForm.useWatch({ control, name: `${effectiveName}.${index}` });
|
|
922
924
|
const summary = React3.useMemo(() => {
|
|
923
|
-
if (!isCollapsed) return
|
|
924
|
-
if (!rowValues) return
|
|
925
|
-
return getRowSummary(rowValues, itemConfig, index);
|
|
926
|
-
}, [
|
|
927
|
-
|
|
925
|
+
if (!isCollapsed) return fallback;
|
|
926
|
+
if (!rowValues) return fallback;
|
|
927
|
+
return getRowSummary(rowValues, itemConfig, index, labels.arrayItemSummary);
|
|
928
|
+
}, [
|
|
929
|
+
isCollapsed,
|
|
930
|
+
rowValues,
|
|
931
|
+
itemConfig,
|
|
932
|
+
index,
|
|
933
|
+
fallback,
|
|
934
|
+
labels.arrayItemSummary
|
|
935
|
+
]);
|
|
936
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: isCollapsed ? summary : fallback });
|
|
928
937
|
}
|
|
929
938
|
function getEffectiveName(field, namePrefix) {
|
|
930
939
|
if (!namePrefix) return field.name;
|