@firecms/core 3.5.2-canary.09e1281 → 3.5.2-canary.a0001bd

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.
Files changed (32) hide show
  1. package/dist/components/EntityCollectionView/utils.d.ts +1 -0
  2. package/dist/{de-CUF9f7S-.js → de-CNfJQcnh.js} +1 -1
  3. package/dist/{de-CUF9f7S-.js.map → de-CNfJQcnh.js.map} +1 -1
  4. package/dist/{editor-WZytSO_1.js → editor-D0A5yaaJ.js} +1 -1
  5. package/dist/{editor-WZytSO_1.js.map → editor-D0A5yaaJ.js.map} +1 -1
  6. package/dist/{fr-DmkMX6hp.js → fr-CBtSvDVp.js} +1 -1
  7. package/dist/{fr-DmkMX6hp.js.map → fr-CBtSvDVp.js.map} +1 -1
  8. package/dist/{hi-BKuaMr7w.js → hi-Delc4l61.js} +1 -1
  9. package/dist/{hi-BKuaMr7w.js.map → hi-Delc4l61.js.map} +1 -1
  10. package/dist/index.es.js +101 -197
  11. package/dist/index.es.js.map +1 -1
  12. package/dist/index.umd.js +93 -189
  13. package/dist/index.umd.js.map +1 -1
  14. package/dist/{it-BwQflFGz.js → it-CdsoaRVO.js} +1 -1
  15. package/dist/{it-BwQflFGz.js.map → it-CdsoaRVO.js.map} +1 -1
  16. package/dist/{pl-BPsAvZvc.js → pl-DoTvWcwp.js} +1 -1
  17. package/dist/{pl-BPsAvZvc.js.map → pl-DoTvWcwp.js.map} +1 -1
  18. package/dist/preview/components/__tests__/DatePreview.test.d.ts +1 -0
  19. package/dist/{pt-D5q7OQp1.js → pt-DCfk8Nkq.js} +1 -1
  20. package/dist/{pt-D5q7OQp1.js.map → pt-DCfk8Nkq.js.map} +1 -1
  21. package/dist/types/locales.d.ts +1 -1
  22. package/dist/util/__tests__/locales.test.d.ts +1 -0
  23. package/dist/util/date_fns_locales.d.ts +13 -0
  24. package/package.json +3 -3
  25. package/src/components/EntityCollectionView/EntityIdHeaderWidget.tsx +50 -8
  26. package/src/components/EntityCollectionView/utils.ts +6 -0
  27. package/src/form/field_bindings/BlockFieldBinding.tsx +2 -1
  28. package/src/preview/components/DatePreview.tsx +14 -2
  29. package/src/preview/components/__tests__/DatePreview.test.tsx +39 -0
  30. package/src/types/locales.ts +2 -0
  31. package/src/util/__tests__/locales.test.ts +46 -0
  32. package/src/util/date_fns_locales.ts +28 -0
package/dist/index.umd.js CHANGED
@@ -4848,6 +4848,16 @@
4848
4848
  function _temp$I(count) {
4849
4849
  return count + 1;
4850
4850
  }
4851
+ const supportedLocales = new Map([...Object.keys(loaders), "en", "fil"].map((locale) => [locale.toLowerCase(), locale]));
4852
+ function resolveLocale(value) {
4853
+ if (typeof value !== "string") return void 0;
4854
+ const parts = value.trim().split(/[-_\s]+/).filter(Boolean);
4855
+ if (parts.length === 0) return void 0;
4856
+ return supportedLocales.get(parts.join("").toLowerCase()) ?? supportedLocales.get(parts[0].toLowerCase());
4857
+ }
4858
+ function localeToLanguageTag(locale) {
4859
+ return locale.replace(/^([a-z]{2,3})([A-Z][A-Za-z]+)$/, "$1-$2");
4860
+ }
4851
4861
  const CONTAINER_FULL_WIDTH = "100vw";
4852
4862
  const ADDITIONAL_TAB_WIDTH = "55vw";
4853
4863
  const FORM_CONTAINER_WIDTH = "768px";
@@ -7730,6 +7740,13 @@
7730
7740
  }
7731
7741
  return t3;
7732
7742
  }
7743
+ function dateTimeFormat(locale, options) {
7744
+ try {
7745
+ return new Intl.DateTimeFormat(locale ? localeToLanguageTag(locale) : "en-US", options);
7746
+ } catch {
7747
+ return new Intl.DateTimeFormat("en-US", options);
7748
+ }
7749
+ }
7733
7750
  function DatePreview(t0) {
7734
7751
  const $ = reactCompilerRuntime.c(22);
7735
7752
  const {
@@ -7763,7 +7780,7 @@
7763
7780
  options.hour = "2-digit";
7764
7781
  options.minute = "2-digit";
7765
7782
  }
7766
- const formatter = new Intl.DateTimeFormat(customizationController?.locale ?? "en-US", options);
7783
+ const formatter = dateTimeFormat(customizationController?.locale, options);
7767
7784
  t22 = formatter.format(date);
7768
7785
  $[1] = customizationController?.locale;
7769
7786
  $[2] = date;
@@ -15872,10 +15889,11 @@
15872
15889
  setValue(null);
15873
15890
  }, children: /* @__PURE__ */ jsxRuntime.jsx(ui.CloseIcon, { size: "small" }) })
15874
15891
  ] });
15892
+ const canAddElements = !property.disabled && !isSubmitting && !disabled && (property.canAddElements ?? true);
15875
15893
  const firstOneOfKey = Object.keys(property.oneOf.properties)[0];
15876
15894
  const body = /* @__PURE__ */ jsxRuntime.jsx(ArrayContainer, { value, className: "flex flex-col gap-3", droppableId: propertyKey, addLabel: property.name ? t("add_to_field", {
15877
15895
  fieldName: property.name
15878
- }) : t("add_entry"), buildEntry, onInternalIdAdded: setLastAddedId, disabled: isSubmitting || Boolean(property.disabled), canAddElements: !property.disabled, onValueChange: (value_0) => setFieldValue(propertyKey, value_0), newDefaultEntry: {
15896
+ }) : t("add_entry"), buildEntry, onInternalIdAdded: setLastAddedId, disabled: isSubmitting || Boolean(property.disabled), canAddElements, onValueChange: (value_0) => setFieldValue(propertyKey, value_0), newDefaultEntry: {
15879
15897
  [property.oneOf.typeField ?? DEFAULT_ONE_OF_TYPE]: firstOneOfKey,
15880
15898
  [property.oneOf.valueField ?? DEFAULT_ONE_OF_VALUE]: getDefaultValueFor(property.oneOf.properties[firstOneOfKey])
15881
15899
  } });
@@ -21084,6 +21102,11 @@
21084
21102
  function getRecentIds(key) {
21085
21103
  return getLocalStorageJSON("recent_id_searches::" + key, []);
21086
21104
  }
21105
+ function removeRecentIds(key, ids) {
21106
+ const remaining = getRecentIds(key).filter((id) => !ids.includes(id));
21107
+ saveSearchedIdsLocally(key, remaining);
21108
+ return remaining;
21109
+ }
21087
21110
  const editEntityAction = {
21088
21111
  icon: /* @__PURE__ */ jsxRuntime.jsx(ui.EditIcon, { size: "small" }),
21089
21112
  key: "edit",
@@ -26595,164 +26618,86 @@
26595
26618
  return key_0.toString();
26596
26619
  }
26597
26620
  const DEFAULT_ENTITY_OPEN_MODE$1 = "side_panel";
26598
- function EntityIdHeaderWidget(t0) {
26599
- const $ = reactCompilerRuntime.c(53);
26600
- const {
26601
- collection,
26602
- path,
26603
- pathSegments,
26604
- fullIdPath
26605
- } = t0;
26621
+ function EntityIdHeaderWidget({
26622
+ collection,
26623
+ path,
26624
+ pathSegments,
26625
+ fullIdPath
26626
+ }) {
26606
26627
  const navigation = useNavigationController();
26628
+ const dataSource = useDataSource();
26607
26629
  const [openPopup, setOpenPopup] = React.useState(false);
26608
26630
  const [searchString, setSearchString] = React.useState("");
26609
- let t1;
26610
- if ($[0] !== fullIdPath) {
26611
- t1 = () => getRecentIds(fullIdPath);
26612
- $[0] = fullIdPath;
26613
- $[1] = t1;
26614
- } else {
26615
- t1 = $[1];
26616
- }
26617
- const [recentIds, setRecentIds] = React.useState(t1);
26631
+ const [recentIds, setRecentIds] = React.useState([]);
26632
+ const latestCheck = React.useRef(0);
26618
26633
  const sideEntityController = useSideEntityController();
26619
26634
  const {
26620
26635
  t
26621
26636
  } = useTranslation();
26637
+ const resolvedPath = navigation.resolveIdsFrom(path, pathSegments);
26638
+ const resolvedPathSegments = pathSegments ? navigation.resolveSegmentsFrom?.(pathSegments) ?? pathSegments : void 0;
26639
+ const entityExists = React.useCallback(async (entityId) => {
26640
+ try {
26641
+ const entity = await dataSource.fetchEntity({
26642
+ path: resolvedPath,
26643
+ pathSegments: resolvedPathSegments,
26644
+ entityId,
26645
+ collection
26646
+ });
26647
+ return Boolean(entity?.values);
26648
+ } catch (e) {
26649
+ return void 0;
26650
+ }
26651
+ }, [dataSource, resolvedPath, resolvedPathSegments, collection]);
26652
+ const refreshRecentIds = () => {
26653
+ const ids = getRecentIds(fullIdPath);
26654
+ const check = ++latestCheck.current;
26655
+ Promise.all(ids.map(entityExists)).then((results) => {
26656
+ if (check !== latestCheck.current) return;
26657
+ const missing = ids.filter((_, i) => results[i] === false);
26658
+ if (missing.length > 0) removeRecentIds(fullIdPath, missing);
26659
+ setRecentIds(ids.filter((__0, i_0) => results[i_0] === true));
26660
+ });
26661
+ };
26622
26662
  const openEntityMode = collection?.openEntityMode ?? DEFAULT_ENTITY_OPEN_MODE$1;
26623
- let t2;
26624
- if ($[2] !== openPopup || $[3] !== t) {
26625
- t2 = !openPopup ? t("find_by_id") : void 0;
26626
- $[2] = openPopup;
26627
- $[3] = t;
26628
- $[4] = t2;
26629
- } else {
26630
- t2 = $[4];
26631
- }
26632
- let t3;
26633
- if ($[5] !== fullIdPath) {
26634
- t3 = (open) => {
26635
- if (open) {
26636
- setRecentIds(getRecentIds(fullIdPath));
26637
- }
26638
- setOpenPopup(open);
26639
- };
26640
- $[5] = fullIdPath;
26641
- $[6] = t3;
26642
- } else {
26643
- t3 = $[6];
26644
- }
26645
- let t4;
26646
- let t5;
26647
- if ($[7] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
26648
- t4 = /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "small", children: /* @__PURE__ */ jsxRuntime.jsx(ui.SearchIcon, { size: "small" }) });
26649
- t5 = ui.cls("my-2 rounded-lg bg-surface-50 dark:bg-surface-950 text-surface-900 dark:text-white");
26650
- $[7] = t4;
26651
- $[8] = t5;
26652
- } else {
26653
- t4 = $[7];
26654
- t5 = $[8];
26655
- }
26656
- let t6;
26657
- if ($[9] !== collection || $[10] !== fullIdPath || $[11] !== navigation || $[12] !== openEntityMode || $[13] !== path || $[14] !== pathSegments || $[15] !== searchString || $[16] !== sideEntityController) {
26658
- t6 = (e) => {
26659
- e.preventDefault();
26660
- const entityId = searchString.trim();
26661
- if (!entityId) {
26662
- return;
26663
- }
26663
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: !openPopup ? t("find_by_id") : void 0, asChild: false, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Popover, { open: openPopup, onOpenChange: (open) => {
26664
+ if (open) refreshRecentIds();
26665
+ setOpenPopup(open);
26666
+ }, sideOffset: 0, align: "start", alignOffset: -117, trigger: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "small", children: /* @__PURE__ */ jsxRuntime.jsx(ui.SearchIcon, { size: "small" }) }), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls("my-2 rounded-lg bg-surface-50 dark:bg-surface-950 text-surface-900 dark:text-white"), children: [
26667
+ /* @__PURE__ */ jsxRuntime.jsx("form", { noValidate: true, onSubmit: (e_0) => {
26668
+ e_0.preventDefault();
26669
+ const entityId_0 = searchString.trim();
26670
+ if (!entityId_0) return;
26664
26671
  setOpenPopup(false);
26665
- setRecentIds(addRecentId(fullIdPath, entityId));
26672
+ entityExists(entityId_0).then((exists) => {
26673
+ if (exists) addRecentId(fullIdPath, entityId_0);
26674
+ });
26666
26675
  navigateToEntity({
26667
26676
  openEntityMode,
26668
26677
  collection,
26669
- entityId,
26678
+ entityId: entityId_0,
26670
26679
  path,
26671
26680
  pathSegments,
26672
26681
  fullIdPath,
26673
26682
  sideEntityController,
26674
26683
  navigation
26675
26684
  });
26676
- };
26677
- $[9] = collection;
26678
- $[10] = fullIdPath;
26679
- $[11] = navigation;
26680
- $[12] = openEntityMode;
26681
- $[13] = path;
26682
- $[14] = pathSegments;
26683
- $[15] = searchString;
26684
- $[16] = sideEntityController;
26685
- $[17] = t6;
26686
- } else {
26687
- t6 = $[17];
26688
- }
26689
- let t7;
26690
- if ($[18] !== t) {
26691
- t7 = t("find_entity_by_id");
26692
- $[18] = t;
26693
- $[19] = t7;
26694
- } else {
26695
- t7 = $[19];
26696
- }
26697
- let t8;
26698
- if ($[20] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
26699
- t8 = (e_0) => {
26700
- setSearchString(e_0.target.value);
26701
- };
26702
- $[20] = t8;
26703
- } else {
26704
- t8 = $[20];
26705
- }
26706
- let t9;
26707
- if ($[21] !== openPopup || $[22] !== searchString || $[23] !== t7) {
26708
- t9 = /* @__PURE__ */ jsxRuntime.jsx("input", { autoFocus: openPopup, placeholder: t7, onChange: t8, value: searchString, className: "rounded-lg bg-white dark:bg-surface-800 flex-grow bg-transparent outline-none p-2 " + ui.focusedDisabled });
26709
- $[21] = openPopup;
26710
- $[22] = searchString;
26711
- $[23] = t7;
26712
- $[24] = t9;
26713
- } else {
26714
- t9 = $[24];
26715
- }
26716
- const t10 = !searchString.trim();
26717
- let t11;
26718
- if ($[25] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
26719
- t11 = /* @__PURE__ */ jsxRuntime.jsx(ui.KeyboardTabIcon, {});
26720
- $[25] = t11;
26721
- } else {
26722
- t11 = $[25];
26723
- }
26724
- let t12;
26725
- if ($[26] !== t10) {
26726
- t12 = /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "text", disabled: t10, type: "submit", children: t11 });
26727
- $[26] = t10;
26728
- $[27] = t12;
26729
- } else {
26730
- t12 = $[27];
26731
- }
26732
- let t13;
26733
- if ($[28] !== t12 || $[29] !== t9) {
26734
- t13 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex p-2 w-full gap-2", children: [
26735
- t9,
26736
- t12
26737
- ] });
26738
- $[28] = t12;
26739
- $[29] = t9;
26740
- $[30] = t13;
26741
- } else {
26742
- t13 = $[30];
26743
- }
26744
- let t14;
26745
- if ($[31] !== t13 || $[32] !== t6) {
26746
- t14 = /* @__PURE__ */ jsxRuntime.jsx("form", { noValidate: true, onSubmit: t6, className: "w-96 max-w-full", children: t13 });
26747
- $[31] = t13;
26748
- $[32] = t6;
26749
- $[33] = t14;
26750
- } else {
26751
- t14 = $[33];
26752
- }
26753
- let t15;
26754
- if ($[34] !== collection || $[35] !== fullIdPath || $[36] !== navigation || $[37] !== openEntityMode || $[38] !== path || $[39] !== pathSegments || $[40] !== recentIds || $[41] !== sideEntityController) {
26755
- t15 = recentIds && recentIds.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2 p-2", children: recentIds.map((id) => /* @__PURE__ */ jsxRuntime.jsx(ReferencePreview, { reference: new EntityReference(id, path, void 0, pathSegments), hover: true, onClick: () => {
26685
+ }, className: "w-96 max-w-full", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex p-2 w-full gap-2", children: [
26686
+ /* @__PURE__ */ jsxRuntime.jsx(
26687
+ "input",
26688
+ {
26689
+ autoFocus: openPopup,
26690
+ placeholder: t("find_entity_by_id"),
26691
+ onChange: (e_1) => {
26692
+ setSearchString(e_1.target.value);
26693
+ },
26694
+ value: searchString,
26695
+ className: "rounded-lg bg-white dark:bg-surface-800 flex-grow bg-transparent outline-none p-2 " + ui.focusedDisabled
26696
+ }
26697
+ ),
26698
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "text", disabled: !searchString.trim(), type: "submit", children: /* @__PURE__ */ jsxRuntime.jsx(ui.KeyboardTabIcon, {}) })
26699
+ ] }) }),
26700
+ recentIds && recentIds.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2 p-2", children: recentIds.map((id) => /* @__PURE__ */ jsxRuntime.jsx(ReferencePreview, { reference: new EntityReference(id, path, void 0, pathSegments), hover: true, onClick: () => {
26756
26701
  setOpenPopup(false);
26757
26702
  navigateToEntity({
26758
26703
  openEntityMode,
@@ -26764,51 +26709,8 @@
26764
26709
  sideEntityController,
26765
26710
  navigation
26766
26711
  });
26767
- }, includeEntityLink: false, size: "small" }, id)) });
26768
- $[34] = collection;
26769
- $[35] = fullIdPath;
26770
- $[36] = navigation;
26771
- $[37] = openEntityMode;
26772
- $[38] = path;
26773
- $[39] = pathSegments;
26774
- $[40] = recentIds;
26775
- $[41] = sideEntityController;
26776
- $[42] = t15;
26777
- } else {
26778
- t15 = $[42];
26779
- }
26780
- let t16;
26781
- if ($[43] !== t14 || $[44] !== t15) {
26782
- t16 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t5, children: [
26783
- t14,
26784
- t15
26785
- ] });
26786
- $[43] = t14;
26787
- $[44] = t15;
26788
- $[45] = t16;
26789
- } else {
26790
- t16 = $[45];
26791
- }
26792
- let t17;
26793
- if ($[46] !== openPopup || $[47] !== t16 || $[48] !== t3) {
26794
- t17 = /* @__PURE__ */ jsxRuntime.jsx(ui.Popover, { open: openPopup, onOpenChange: t3, sideOffset: 0, align: "start", alignOffset: -117, trigger: t4, children: t16 });
26795
- $[46] = openPopup;
26796
- $[47] = t16;
26797
- $[48] = t3;
26798
- $[49] = t17;
26799
- } else {
26800
- t17 = $[49];
26801
- }
26802
- let t18;
26803
- if ($[50] !== t17 || $[51] !== t2) {
26804
- t18 = /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: t2, asChild: false, children: t17 });
26805
- $[50] = t17;
26806
- $[51] = t2;
26807
- $[52] = t18;
26808
- } else {
26809
- t18 = $[52];
26810
- }
26811
- return t18;
26712
+ }, includeEntityLink: false, size: "small" }, id)) })
26713
+ ] }) }) });
26812
26714
  }
26813
26715
  const collectionScrollCache = /* @__PURE__ */ new Map();
26814
26716
  function useScrollRestoration() {
@@ -32768,7 +32670,7 @@
32768
32670
  children,
32769
32671
  entityLinkBuilder,
32770
32672
  userConfigPersistence,
32771
- dateTimeFormat,
32673
+ dateTimeFormat: dateTimeFormat2,
32772
32674
  locale,
32773
32675
  authController,
32774
32676
  storageSource,
@@ -32817,7 +32719,7 @@
32817
32719
  const pluginsLoading = plugins?.some((p_0) => p_0.loading) ?? false;
32818
32720
  const loading = authController.initialLoading || navigationController.loading || pluginsLoading;
32819
32721
  const customizationController = {
32820
- dateTimeFormat,
32722
+ dateTimeFormat: dateTimeFormat2,
32821
32723
  locale,
32822
32724
  entityLinkBuilder,
32823
32725
  plugins,
@@ -45210,6 +45112,7 @@ ul[data-type="taskList"] li[data-checked="true"] > div > p {
45210
45112
  exports2.jsonStringifyReplacer = jsonStringifyReplacer;
45211
45113
  exports2.lazyEager = lazyEager;
45212
45114
  exports2.loadDateFnsLocale = loadDateFnsLocale;
45115
+ exports2.localeToLanguageTag = localeToLanguageTag;
45213
45116
  exports2.makePropertiesEditable = makePropertiesEditable;
45214
45117
  exports2.mergeCallbacks = mergeCallbacks;
45215
45118
  exports2.mergeCollection = mergeCollection;
@@ -45247,6 +45150,7 @@ ul[data-type="taskList"] li[data-checked="true"] > div > p {
45247
45150
  exports2.resolveEntityAction = resolveEntityAction;
45248
45151
  exports2.resolveEntityView = resolveEntityView;
45249
45152
  exports2.resolveEnumValues = resolveEnumValues;
45153
+ exports2.resolveLocale = resolveLocale;
45250
45154
  exports2.resolveNavigationFrom = resolveNavigationFrom;
45251
45155
  exports2.resolvePermissions = resolvePermissions;
45252
45156
  exports2.resolveProperties = resolveProperties;