@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.mjs
CHANGED
|
@@ -698,7 +698,7 @@ function getDefaultValue(field) {
|
|
|
698
698
|
return void 0;
|
|
699
699
|
}
|
|
700
700
|
}
|
|
701
|
-
function getRowSummary(row, itemConfig, index) {
|
|
701
|
+
function getRowSummary(row, itemConfig, index, itemSummary) {
|
|
702
702
|
if (itemConfig.type === "object") {
|
|
703
703
|
for (const child of itemConfig.children) {
|
|
704
704
|
const key = child.name.split(".").pop() ?? child.name;
|
|
@@ -708,7 +708,7 @@ function getRowSummary(row, itemConfig, index) {
|
|
|
708
708
|
}
|
|
709
709
|
}
|
|
710
710
|
}
|
|
711
|
-
return `Item ${index + 1}`;
|
|
711
|
+
return itemSummary?.(index) ?? `Item ${index + 1}`;
|
|
712
712
|
}
|
|
713
713
|
function ArrayField({ field, control, effectiveName }) {
|
|
714
714
|
const { classNames, layout, labels } = useAutoFormContext();
|
|
@@ -765,7 +765,7 @@ function ArrayField({ field, control, effectiveName }) {
|
|
|
765
765
|
type: "button",
|
|
766
766
|
className: classNames.arrayCollapse,
|
|
767
767
|
onClick: () => toggleCollapse(index),
|
|
768
|
-
"aria-label": isCollapsed ? `Expand item ${index + 1}` : `Collapse item ${index + 1}`,
|
|
768
|
+
"aria-label": isCollapsed ? labels.arrayAriaExpand?.(index) ?? `Expand item ${index + 1}` : labels.arrayAriaCollapse?.(index) ?? `Collapse item ${index + 1}`,
|
|
769
769
|
isCollapsed,
|
|
770
770
|
children: [
|
|
771
771
|
isCollapsed ? labels.arrayExpand ?? "\u25BC" : labels.arrayCollapse ?? "\u25B6",
|
|
@@ -790,7 +790,7 @@ function ArrayField({ field, control, effectiveName }) {
|
|
|
790
790
|
className: classNames.arrayMove,
|
|
791
791
|
onClick: () => move(index, index - 1),
|
|
792
792
|
disabled: index === 0,
|
|
793
|
-
"aria-label": `Move item ${index + 1} up`,
|
|
793
|
+
"aria-label": labels.arrayAriaMoveUp?.(index) ?? `Move item ${index + 1} up`,
|
|
794
794
|
children: labels.arrayMoveUp ?? "\u2191"
|
|
795
795
|
}
|
|
796
796
|
) : null;
|
|
@@ -801,7 +801,7 @@ function ArrayField({ field, control, effectiveName }) {
|
|
|
801
801
|
className: classNames.arrayMove,
|
|
802
802
|
onClick: () => move(index, index + 1),
|
|
803
803
|
disabled: index === rows.length - 1,
|
|
804
|
-
"aria-label": `Move item ${index + 1} down`,
|
|
804
|
+
"aria-label": labels.arrayAriaMoveDown?.(index) ?? `Move item ${index + 1} down`,
|
|
805
805
|
children: labels.arrayMoveDown ?? "\u2193"
|
|
806
806
|
}
|
|
807
807
|
) : null;
|
|
@@ -816,7 +816,7 @@ function ArrayField({ field, control, effectiveName }) {
|
|
|
816
816
|
);
|
|
817
817
|
insert(index + 1, values);
|
|
818
818
|
},
|
|
819
|
-
"aria-label": `Duplicate item ${index + 1}`,
|
|
819
|
+
"aria-label": labels.arrayAriaDuplicate?.(index) ?? `Duplicate item ${index + 1}`,
|
|
820
820
|
children: labels.arrayDuplicate ?? "Duplicate"
|
|
821
821
|
}
|
|
822
822
|
) : null;
|
|
@@ -827,7 +827,7 @@ function ArrayField({ field, control, effectiveName }) {
|
|
|
827
827
|
className: classNames.arrayRemove,
|
|
828
828
|
onClick: () => remove(index),
|
|
829
829
|
disabled: atMin,
|
|
830
|
-
"aria-label": `Remove item ${index + 1}`,
|
|
830
|
+
"aria-label": labels.arrayAriaRemove?.(index) ?? `Remove item ${index + 1}`,
|
|
831
831
|
children: labels.arrayRemove ?? "Remove"
|
|
832
832
|
}
|
|
833
833
|
);
|
|
@@ -896,13 +896,22 @@ function CollapseSummary({
|
|
|
896
896
|
itemConfig,
|
|
897
897
|
isCollapsed
|
|
898
898
|
}) {
|
|
899
|
+
const { labels } = useAutoFormContext();
|
|
900
|
+
const fallback = labels.arrayItemSummary?.(index) ?? `Item ${index + 1}`;
|
|
899
901
|
const rowValues = useWatch({ control, name: `${effectiveName}.${index}` });
|
|
900
902
|
const summary = useMemo(() => {
|
|
901
|
-
if (!isCollapsed) return
|
|
902
|
-
if (!rowValues) return
|
|
903
|
-
return getRowSummary(rowValues, itemConfig, index);
|
|
904
|
-
}, [
|
|
905
|
-
|
|
903
|
+
if (!isCollapsed) return fallback;
|
|
904
|
+
if (!rowValues) return fallback;
|
|
905
|
+
return getRowSummary(rowValues, itemConfig, index, labels.arrayItemSummary);
|
|
906
|
+
}, [
|
|
907
|
+
isCollapsed,
|
|
908
|
+
rowValues,
|
|
909
|
+
itemConfig,
|
|
910
|
+
index,
|
|
911
|
+
fallback,
|
|
912
|
+
labels.arrayItemSummary
|
|
913
|
+
]);
|
|
914
|
+
return /* @__PURE__ */ jsx(Fragment, { children: isCollapsed ? summary : fallback });
|
|
906
915
|
}
|
|
907
916
|
function getEffectiveName(field, namePrefix) {
|
|
908
917
|
if (!namePrefix) return field.name;
|