@ceed/ads 1.8.0-next.6 → 1.8.0-next.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/dist/index.cjs CHANGED
@@ -4690,6 +4690,12 @@ function DateRange(props) {
4690
4690
  const now = /* @__PURE__ */ new Date();
4691
4691
  const currentYear = now.getFullYear();
4692
4692
  const currentMonth = now.getMonth();
4693
+ const formatDate = (date) => {
4694
+ const year = date.getFullYear();
4695
+ const month = String(date.getMonth() + 1).padStart(2, "0");
4696
+ const day = String(date.getDate()).padStart(2, "0");
4697
+ return `${year}-${month}-${day}`;
4698
+ };
4693
4699
  switch (option) {
4694
4700
  case "all-time":
4695
4701
  return null;
@@ -4697,24 +4703,26 @@ function DateRange(props) {
4697
4703
  const startOfMonth = new Date(currentYear, currentMonth, 1);
4698
4704
  const endOfMonth = new Date(currentYear, currentMonth + 1, 0);
4699
4705
  return [
4700
- startOfMonth.toISOString().split("T")[0],
4701
- endOfMonth.toISOString().split("T")[0]
4706
+ formatDate(startOfMonth),
4707
+ formatDate(endOfMonth)
4702
4708
  ];
4703
4709
  }
4704
4710
  case "this-year": {
4705
4711
  const startOfYear = new Date(currentYear, 0, 1);
4706
4712
  const endOfYear = new Date(currentYear, 11, 31);
4707
4713
  return [
4708
- startOfYear.toISOString().split("T")[0],
4709
- endOfYear.toISOString().split("T")[0]
4714
+ formatDate(startOfYear),
4715
+ formatDate(endOfYear)
4710
4716
  ];
4711
4717
  }
4712
4718
  case "last-month": {
4713
- const startOfLastMonth = new Date(currentYear, currentMonth - 1, 1);
4714
- const endOfLastMonth = new Date(currentYear, currentMonth, 0);
4719
+ const lastMonthYear = currentMonth === 0 ? currentYear - 1 : currentYear;
4720
+ const lastMonth = currentMonth === 0 ? 11 : currentMonth - 1;
4721
+ const startOfLastMonth = new Date(lastMonthYear, lastMonth, 1);
4722
+ const endOfLastMonth = new Date(lastMonthYear, lastMonth + 1, 0);
4715
4723
  return [
4716
- startOfLastMonth.toISOString().split("T")[0],
4717
- endOfLastMonth.toISOString().split("T")[0]
4724
+ formatDate(startOfLastMonth),
4725
+ formatDate(endOfLastMonth)
4718
4726
  ];
4719
4727
  }
4720
4728
  case "custom":
@@ -4725,12 +4733,32 @@ function DateRange(props) {
4725
4733
  },
4726
4734
  [internalValue]
4727
4735
  );
4736
+ const determineOptionFromValue = (0, import_react32.useCallback)(
4737
+ (value2) => {
4738
+ if (!value2) {
4739
+ return "all-time";
4740
+ }
4741
+ const options = ["this-month", "this-year", "last-month"];
4742
+ for (const option of options) {
4743
+ const optionRange = getDateRangeForOption(option);
4744
+ if (optionRange && optionRange[0] === value2[0] && optionRange[1] === value2[1]) {
4745
+ return option;
4746
+ }
4747
+ }
4748
+ return "custom";
4749
+ },
4750
+ [getDateRangeForOption]
4751
+ );
4728
4752
  const customDateRangeValue = (0, import_react32.useMemo)(() => {
4729
4753
  if (selectedOption === "custom" && internalValue) {
4730
4754
  return `${internalValue[0]} - ${internalValue[1]}`;
4731
4755
  }
4732
4756
  return "";
4733
4757
  }, [selectedOption, internalValue]);
4758
+ (0, import_react32.useEffect)(() => {
4759
+ const newOption = determineOptionFromValue(internalValue);
4760
+ setSelectedOption(newOption);
4761
+ }, [internalValue, determineOptionFromValue]);
4734
4762
  const handleOptionChange = (0, import_react32.useCallback)(
4735
4763
  (event) => {
4736
4764
  const newOption = event.target.value;
package/dist/index.js CHANGED
@@ -4622,7 +4622,7 @@ function RadioGroup2(props) {
4622
4622
  RadioGroup2.displayName = "RadioGroup";
4623
4623
 
4624
4624
  // src/components/FilterMenu/components/DateRange.tsx
4625
- import React30, { useCallback as useCallback13, useMemo as useMemo10, useState as useState8 } from "react";
4625
+ import React30, { useCallback as useCallback13, useMemo as useMemo10, useState as useState8, useEffect as useEffect7 } from "react";
4626
4626
  import { Stack as Stack4 } from "@mui/joy";
4627
4627
  function DateRange(props) {
4628
4628
  const {
@@ -4660,6 +4660,12 @@ function DateRange(props) {
4660
4660
  const now = /* @__PURE__ */ new Date();
4661
4661
  const currentYear = now.getFullYear();
4662
4662
  const currentMonth = now.getMonth();
4663
+ const formatDate = (date) => {
4664
+ const year = date.getFullYear();
4665
+ const month = String(date.getMonth() + 1).padStart(2, "0");
4666
+ const day = String(date.getDate()).padStart(2, "0");
4667
+ return `${year}-${month}-${day}`;
4668
+ };
4663
4669
  switch (option) {
4664
4670
  case "all-time":
4665
4671
  return null;
@@ -4667,24 +4673,26 @@ function DateRange(props) {
4667
4673
  const startOfMonth = new Date(currentYear, currentMonth, 1);
4668
4674
  const endOfMonth = new Date(currentYear, currentMonth + 1, 0);
4669
4675
  return [
4670
- startOfMonth.toISOString().split("T")[0],
4671
- endOfMonth.toISOString().split("T")[0]
4676
+ formatDate(startOfMonth),
4677
+ formatDate(endOfMonth)
4672
4678
  ];
4673
4679
  }
4674
4680
  case "this-year": {
4675
4681
  const startOfYear = new Date(currentYear, 0, 1);
4676
4682
  const endOfYear = new Date(currentYear, 11, 31);
4677
4683
  return [
4678
- startOfYear.toISOString().split("T")[0],
4679
- endOfYear.toISOString().split("T")[0]
4684
+ formatDate(startOfYear),
4685
+ formatDate(endOfYear)
4680
4686
  ];
4681
4687
  }
4682
4688
  case "last-month": {
4683
- const startOfLastMonth = new Date(currentYear, currentMonth - 1, 1);
4684
- const endOfLastMonth = new Date(currentYear, currentMonth, 0);
4689
+ const lastMonthYear = currentMonth === 0 ? currentYear - 1 : currentYear;
4690
+ const lastMonth = currentMonth === 0 ? 11 : currentMonth - 1;
4691
+ const startOfLastMonth = new Date(lastMonthYear, lastMonth, 1);
4692
+ const endOfLastMonth = new Date(lastMonthYear, lastMonth + 1, 0);
4685
4693
  return [
4686
- startOfLastMonth.toISOString().split("T")[0],
4687
- endOfLastMonth.toISOString().split("T")[0]
4694
+ formatDate(startOfLastMonth),
4695
+ formatDate(endOfLastMonth)
4688
4696
  ];
4689
4697
  }
4690
4698
  case "custom":
@@ -4695,12 +4703,32 @@ function DateRange(props) {
4695
4703
  },
4696
4704
  [internalValue]
4697
4705
  );
4706
+ const determineOptionFromValue = useCallback13(
4707
+ (value2) => {
4708
+ if (!value2) {
4709
+ return "all-time";
4710
+ }
4711
+ const options = ["this-month", "this-year", "last-month"];
4712
+ for (const option of options) {
4713
+ const optionRange = getDateRangeForOption(option);
4714
+ if (optionRange && optionRange[0] === value2[0] && optionRange[1] === value2[1]) {
4715
+ return option;
4716
+ }
4717
+ }
4718
+ return "custom";
4719
+ },
4720
+ [getDateRangeForOption]
4721
+ );
4698
4722
  const customDateRangeValue = useMemo10(() => {
4699
4723
  if (selectedOption === "custom" && internalValue) {
4700
4724
  return `${internalValue[0]} - ${internalValue[1]}`;
4701
4725
  }
4702
4726
  return "";
4703
4727
  }, [selectedOption, internalValue]);
4728
+ useEffect7(() => {
4729
+ const newOption = determineOptionFromValue(internalValue);
4730
+ setSelectedOption(newOption);
4731
+ }, [internalValue, determineOptionFromValue]);
4704
4732
  const handleOptionChange = useCallback13(
4705
4733
  (event) => {
4706
4734
  const newOption = event.target.value;
@@ -5317,7 +5345,7 @@ FilterMenu.displayName = "FilterMenu";
5317
5345
  // src/components/Uploader/Uploader.tsx
5318
5346
  import React38, {
5319
5347
  useCallback as useCallback20,
5320
- useEffect as useEffect7,
5348
+ useEffect as useEffect8,
5321
5349
  useMemo as useMemo12,
5322
5350
  useRef as useRef6,
5323
5351
  useState as useState10
@@ -5619,7 +5647,7 @@ var Uploader = React38.memo(
5619
5647
  onChange
5620
5648
  ]
5621
5649
  );
5622
- useEffect7(() => {
5650
+ useEffect8(() => {
5623
5651
  if (!dropZoneRef.current || disabled) {
5624
5652
  return;
5625
5653
  }
@@ -5667,7 +5695,7 @@ var Uploader = React38.memo(
5667
5695
  );
5668
5696
  return () => cleanup?.();
5669
5697
  }, [disabled, addFiles]);
5670
- useEffect7(() => {
5698
+ useEffect8(() => {
5671
5699
  if (inputRef.current && minCount) {
5672
5700
  if (files.length < minCount) {
5673
5701
  inputRef.current.setCustomValidity(
@@ -5832,14 +5860,14 @@ function IconMenuButton(props) {
5832
5860
  IconMenuButton.displayName = "IconMenuButton";
5833
5861
 
5834
5862
  // src/components/Markdown/Markdown.tsx
5835
- import React40, { lazy, Suspense, useEffect as useEffect8, useState as useState11 } from "react";
5863
+ import React40, { lazy, Suspense, useEffect as useEffect9, useState as useState11 } from "react";
5836
5864
  import { Skeleton } from "@mui/joy";
5837
5865
  import { Link as Link2 } from "@mui/joy";
5838
5866
  import remarkGfm from "remark-gfm";
5839
5867
  var LazyReactMarkdown = lazy(() => import("react-markdown"));
5840
5868
  var Markdown = (props) => {
5841
5869
  const [rehypeAccent2, setRehypeAccent] = useState11(null);
5842
- useEffect8(() => {
5870
+ useEffect9(() => {
5843
5871
  const loadRehypeAccent = async () => {
5844
5872
  const module = await Promise.resolve().then(() => (init_rehype_accent(), rehype_accent_exports));
5845
5873
  setRehypeAccent(() => module.rehypeAccent);
@@ -5978,7 +6006,7 @@ MenuButton.displayName = "MenuButton";
5978
6006
  import React42, {
5979
6007
  forwardRef as forwardRef9,
5980
6008
  useCallback as useCallback21,
5981
- useEffect as useEffect9,
6009
+ useEffect as useEffect10,
5982
6010
  useImperativeHandle as useImperativeHandle4,
5983
6011
  useRef as useRef7,
5984
6012
  useState as useState12
@@ -6095,7 +6123,7 @@ var MonthPicker = forwardRef9(
6095
6123
  );
6096
6124
  const [anchorEl, setAnchorEl] = useState12(null);
6097
6125
  const open = Boolean(anchorEl);
6098
- useEffect9(() => {
6126
+ useEffect10(() => {
6099
6127
  if (!anchorEl) {
6100
6128
  innerRef.current?.blur();
6101
6129
  }
@@ -6103,7 +6131,7 @@ var MonthPicker = forwardRef9(
6103
6131
  useImperativeHandle4(ref, () => innerRef.current, [
6104
6132
  innerRef
6105
6133
  ]);
6106
- useEffect9(() => {
6134
+ useEffect10(() => {
6107
6135
  setDisplayValue(getFormattedDisplayValue(value));
6108
6136
  }, [value, getFormattedDisplayValue]);
6109
6137
  const handleChange = useCallback21(
@@ -6251,7 +6279,7 @@ var MonthPicker = forwardRef9(
6251
6279
  import React43, {
6252
6280
  forwardRef as forwardRef10,
6253
6281
  useCallback as useCallback22,
6254
- useEffect as useEffect10,
6282
+ useEffect as useEffect11,
6255
6283
  useImperativeHandle as useImperativeHandle5,
6256
6284
  useMemo as useMemo13,
6257
6285
  useRef as useRef8,
@@ -6382,7 +6410,7 @@ var MonthRangePicker = forwardRef10(
6382
6410
  () => value ? parseDates2(value) : void 0,
6383
6411
  [value]
6384
6412
  );
6385
- useEffect10(() => {
6413
+ useEffect11(() => {
6386
6414
  if (!anchorEl) {
6387
6415
  innerRef.current?.blur();
6388
6416
  }