@ceed/ads 1.8.0-next.6 → 1.8.0-next.8

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.js CHANGED
@@ -4121,7 +4121,9 @@ var CalendarButton2 = styled13(IconButton_default, {
4121
4121
  "&:focus": {
4122
4122
  "--Icon-color": "currentColor",
4123
4123
  outlineOffset: `${theme.getCssVar("focus-thickness")}`,
4124
- outline: `${theme.getCssVar("focus-thickness")} solid ${theme.getCssVar("palette-focusVisible")}`
4124
+ outline: `${theme.getCssVar("focus-thickness")} solid ${theme.getCssVar(
4125
+ "palette-focusVisible"
4126
+ )}`
4125
4127
  }
4126
4128
  }));
4127
4129
  var StyledPopper2 = styled13(Popper3, {
@@ -4147,6 +4149,32 @@ var DateRangePickerRoot = styled13("div", {
4147
4149
  })({
4148
4150
  width: "100%"
4149
4151
  });
4152
+ var validValueFormat2 = (value, format) => {
4153
+ try {
4154
+ const [date1Str, date2Str] = value.split(" - ");
4155
+ if (!date1Str || !date2Str) {
4156
+ return false;
4157
+ }
4158
+ const parsedDate1 = parseDate2(date1Str, format);
4159
+ const parsedDate2 = parseDate2(date2Str, format);
4160
+ if (parsedDate1.toString() === "Invalid Date" || parsedDate2.toString() === "Invalid Date") {
4161
+ return false;
4162
+ }
4163
+ const formattedValue = formatValueString2(
4164
+ [parsedDate1, parsedDate2],
4165
+ format
4166
+ );
4167
+ if (value !== formattedValue) {
4168
+ return false;
4169
+ }
4170
+ const regex = new RegExp(
4171
+ `^${format.replace(/Y/g, "\\d").replace(/M/g, "\\d").replace(/D/g, "\\d")} - ${format.replace(/Y/g, "\\d").replace(/M/g, "\\d").replace(/D/g, "\\d")}$`
4172
+ );
4173
+ return regex.test(value);
4174
+ } catch (e) {
4175
+ return false;
4176
+ }
4177
+ };
4150
4178
  var formatValueString2 = ([date1, date2], format) => {
4151
4179
  const getStr = (date) => {
4152
4180
  let day = `${date.getDate()}`;
@@ -4243,6 +4271,7 @@ var DateRangePicker = forwardRef8(
4243
4271
  sx,
4244
4272
  className,
4245
4273
  format = "YYYY/MM/DD",
4274
+ displayFormat = "YYYY/MM/DD",
4246
4275
  size,
4247
4276
  inputReadOnly,
4248
4277
  hideClearButton,
@@ -4259,12 +4288,27 @@ var DateRangePicker = forwardRef8(
4259
4288
  [props.name, onChange]
4260
4289
  )
4261
4290
  );
4291
+ const [displayValue, setDisplayValue] = useState7(
4292
+ () => value ? formatValueString2(parseDates(value, format), displayFormat) : ""
4293
+ );
4262
4294
  const [anchorEl, setAnchorEl] = useState7(null);
4263
4295
  const open = Boolean(anchorEl);
4264
4296
  const calendarValue = useMemo9(
4265
4297
  () => value ? parseDates(value, format) : void 0,
4266
4298
  [value, format]
4267
4299
  );
4300
+ useEffect6(() => {
4301
+ if (value) {
4302
+ try {
4303
+ const dates = parseDates(value, format);
4304
+ const newDisplayValue = formatValueString2(dates, displayFormat);
4305
+ setDisplayValue(newDisplayValue);
4306
+ } catch (error2) {
4307
+ }
4308
+ } else {
4309
+ setDisplayValue("");
4310
+ }
4311
+ }, [displayFormat, value, format]);
4268
4312
  useEffect6(() => {
4269
4313
  if (!anchorEl) {
4270
4314
  innerRef.current?.blur();
@@ -4275,9 +4319,41 @@ var DateRangePicker = forwardRef8(
4275
4319
  ]);
4276
4320
  const handleChange = useCallback10(
4277
4321
  (event) => {
4278
- setValue(event.target.value);
4322
+ const value2 = event.target.value;
4323
+ setDisplayValue(
4324
+ value2 ? formatValueString2(parseDates(value2, format), displayFormat) : value2
4325
+ );
4326
+ setValue(value2);
4279
4327
  },
4280
- [setValue]
4328
+ [displayFormat, format, setValue]
4329
+ );
4330
+ const handleDisplayInputChange = useCallback10(
4331
+ (event) => {
4332
+ if (event.target.value === "") {
4333
+ handleChange({
4334
+ target: {
4335
+ name: props.name,
4336
+ value: ""
4337
+ }
4338
+ });
4339
+ return;
4340
+ }
4341
+ const isValidDisplayValue = validValueFormat2(
4342
+ event.target.value,
4343
+ displayFormat
4344
+ );
4345
+ if (isValidDisplayValue) {
4346
+ const dates = parseDates(event.target.value, displayFormat);
4347
+ const formattedValue = formatValueString2(dates, format);
4348
+ handleChange({
4349
+ target: {
4350
+ name: props.name,
4351
+ value: formattedValue
4352
+ }
4353
+ });
4354
+ }
4355
+ },
4356
+ [displayFormat, format, handleChange, props.name]
4281
4357
  );
4282
4358
  const handleCalendarToggle = useCallback10(
4283
4359
  (event) => {
@@ -4289,10 +4365,26 @@ var DateRangePicker = forwardRef8(
4289
4365
  const handleCalendarChange = useCallback10(
4290
4366
  ([date1, date2]) => {
4291
4367
  if (!date1 || !date2) return;
4292
- setValue(formatValueString2([date1, date2], format));
4368
+ const formattedValue = formatValueString2([date1, date2], format);
4369
+ if (props.value !== void 0) {
4370
+ onChange?.({ target: { name: props.name, value: formattedValue } });
4371
+ } else {
4372
+ setDisplayValue(
4373
+ formatValueString2([date1, date2], displayFormat)
4374
+ );
4375
+ setValue(formattedValue);
4376
+ }
4293
4377
  setAnchorEl(null);
4294
4378
  },
4295
- [setValue, setAnchorEl, format]
4379
+ [
4380
+ props.value,
4381
+ props.name,
4382
+ onChange,
4383
+ setValue,
4384
+ setAnchorEl,
4385
+ format,
4386
+ displayFormat
4387
+ ]
4296
4388
  );
4297
4389
  const handleInputMouseDown = useCallback10(
4298
4390
  (event) => {
@@ -4310,17 +4402,21 @@ var DateRangePicker = forwardRef8(
4310
4402
  color: error ? "danger" : innerProps.color,
4311
4403
  ref,
4312
4404
  size,
4313
- value,
4314
- onChange: handleChange,
4405
+ value: displayValue,
4406
+ onChange: handleDisplayInputChange,
4315
4407
  disabled,
4316
4408
  required,
4317
- placeholder: `${format} - ${format}`,
4409
+ placeholder: `${displayFormat} - ${displayFormat}`,
4318
4410
  slotProps: {
4319
4411
  input: {
4320
4412
  component: TextMaskAdapter5,
4321
4413
  ref: innerRef,
4322
- format,
4323
- sx: { "&:hover": { cursor: inputReadOnly || readOnly ? "default" : "text" } },
4414
+ format: displayFormat,
4415
+ sx: {
4416
+ "&:hover": {
4417
+ cursor: inputReadOnly || readOnly ? "default" : "text"
4418
+ }
4419
+ },
4324
4420
  onMouseDown: handleInputMouseDown
4325
4421
  }
4326
4422
  },
@@ -4390,6 +4486,7 @@ var DateRangePicker = forwardRef8(
4390
4486
  color: "neutral",
4391
4487
  onClick: () => {
4392
4488
  setValue("");
4489
+ setDisplayValue("");
4393
4490
  setAnchorEl(null);
4394
4491
  }
4395
4492
  },
@@ -4552,7 +4649,7 @@ function CheckboxGroup(props) {
4552
4649
  {
4553
4650
  key: `${id}-${option.value}`,
4554
4651
  label: option.label,
4555
- checked: internalValue.includes(option.value),
4652
+ checked: internalValue?.includes(option.value),
4556
4653
  onChange: handleCheckboxChange(option.value)
4557
4654
  }
4558
4655
  )));
@@ -4622,7 +4719,7 @@ function RadioGroup2(props) {
4622
4719
  RadioGroup2.displayName = "RadioGroup";
4623
4720
 
4624
4721
  // src/components/FilterMenu/components/DateRange.tsx
4625
- import React30, { useCallback as useCallback13, useMemo as useMemo10, useState as useState8 } from "react";
4722
+ import React30, { useCallback as useCallback13, useMemo as useMemo10, useState as useState8, useEffect as useEffect7 } from "react";
4626
4723
  import { Stack as Stack4 } from "@mui/joy";
4627
4724
  function DateRange(props) {
4628
4725
  const {
@@ -4636,6 +4733,7 @@ function DateRange(props) {
4636
4733
  disableFuture,
4637
4734
  disablePast,
4638
4735
  format = "YYYY/MM/DD",
4736
+ displayFormat,
4639
4737
  inputReadOnly,
4640
4738
  hideClearButton
4641
4739
  } = props;
@@ -4660,6 +4758,12 @@ function DateRange(props) {
4660
4758
  const now = /* @__PURE__ */ new Date();
4661
4759
  const currentYear = now.getFullYear();
4662
4760
  const currentMonth = now.getMonth();
4761
+ const formatDate = (date) => {
4762
+ const year = date.getFullYear();
4763
+ const month = String(date.getMonth() + 1).padStart(2, "0");
4764
+ const day = String(date.getDate()).padStart(2, "0");
4765
+ return `${year}-${month}-${day}`;
4766
+ };
4663
4767
  switch (option) {
4664
4768
  case "all-time":
4665
4769
  return null;
@@ -4667,24 +4771,26 @@ function DateRange(props) {
4667
4771
  const startOfMonth = new Date(currentYear, currentMonth, 1);
4668
4772
  const endOfMonth = new Date(currentYear, currentMonth + 1, 0);
4669
4773
  return [
4670
- startOfMonth.toISOString().split("T")[0],
4671
- endOfMonth.toISOString().split("T")[0]
4774
+ formatDate(startOfMonth),
4775
+ formatDate(endOfMonth)
4672
4776
  ];
4673
4777
  }
4674
4778
  case "this-year": {
4675
4779
  const startOfYear = new Date(currentYear, 0, 1);
4676
4780
  const endOfYear = new Date(currentYear, 11, 31);
4677
4781
  return [
4678
- startOfYear.toISOString().split("T")[0],
4679
- endOfYear.toISOString().split("T")[0]
4782
+ formatDate(startOfYear),
4783
+ formatDate(endOfYear)
4680
4784
  ];
4681
4785
  }
4682
4786
  case "last-month": {
4683
- const startOfLastMonth = new Date(currentYear, currentMonth - 1, 1);
4684
- const endOfLastMonth = new Date(currentYear, currentMonth, 0);
4787
+ const lastMonthYear = currentMonth === 0 ? currentYear - 1 : currentYear;
4788
+ const lastMonth = currentMonth === 0 ? 11 : currentMonth - 1;
4789
+ const startOfLastMonth = new Date(lastMonthYear, lastMonth, 1);
4790
+ const endOfLastMonth = new Date(lastMonthYear, lastMonth + 1, 0);
4685
4791
  return [
4686
- startOfLastMonth.toISOString().split("T")[0],
4687
- endOfLastMonth.toISOString().split("T")[0]
4792
+ formatDate(startOfLastMonth),
4793
+ formatDate(endOfLastMonth)
4688
4794
  ];
4689
4795
  }
4690
4796
  case "custom":
@@ -4695,12 +4801,32 @@ function DateRange(props) {
4695
4801
  },
4696
4802
  [internalValue]
4697
4803
  );
4804
+ const determineOptionFromValue = useCallback13(
4805
+ (value2) => {
4806
+ if (!value2) {
4807
+ return "all-time";
4808
+ }
4809
+ const options = ["this-month", "this-year", "last-month"];
4810
+ for (const option of options) {
4811
+ const optionRange = getDateRangeForOption(option);
4812
+ if (optionRange && optionRange[0] === value2[0] && optionRange[1] === value2[1]) {
4813
+ return option;
4814
+ }
4815
+ }
4816
+ return "custom";
4817
+ },
4818
+ [getDateRangeForOption]
4819
+ );
4698
4820
  const customDateRangeValue = useMemo10(() => {
4699
4821
  if (selectedOption === "custom" && internalValue) {
4700
4822
  return `${internalValue[0]} - ${internalValue[1]}`;
4701
4823
  }
4702
4824
  return "";
4703
4825
  }, [selectedOption, internalValue]);
4826
+ useEffect7(() => {
4827
+ const newOption = determineOptionFromValue(internalValue);
4828
+ setSelectedOption(newOption);
4829
+ }, [internalValue, determineOptionFromValue]);
4704
4830
  const handleOptionChange = useCallback13(
4705
4831
  (event) => {
4706
4832
  const newOption = event.target.value;
@@ -4762,6 +4888,7 @@ function DateRange(props) {
4762
4888
  disableFuture,
4763
4889
  disablePast,
4764
4890
  format,
4891
+ displayFormat,
4765
4892
  inputReadOnly,
4766
4893
  hideClearButton
4767
4894
  }
@@ -5143,13 +5270,14 @@ function PercentageRange(props) {
5143
5270
  ), /* @__PURE__ */ React35.createElement(Stack8, { direction: "row", spacing: 2, alignItems: "flex-end" }, /* @__PURE__ */ React35.createElement(
5144
5271
  PercentageInput,
5145
5272
  {
5273
+ key: maxValue,
5146
5274
  label: "Minimum",
5147
5275
  value: minValue,
5148
5276
  onChange: handleMinChange,
5149
5277
  useMinorUnit,
5150
5278
  maxDecimalScale,
5151
5279
  min,
5152
- max,
5280
+ max: maxValue || max,
5153
5281
  "aria-labelledby": label ? id : void 0,
5154
5282
  "aria-label": "Minimum percentage",
5155
5283
  placeholder: "0%"
@@ -5157,12 +5285,13 @@ function PercentageRange(props) {
5157
5285
  ), /* @__PURE__ */ React35.createElement(
5158
5286
  PercentageInput,
5159
5287
  {
5288
+ key: minValue,
5160
5289
  label: "Maximum",
5161
5290
  value: maxValue,
5162
5291
  onChange: handleMaxChange,
5163
5292
  useMinorUnit,
5164
5293
  maxDecimalScale,
5165
- min,
5294
+ min: minValue || min,
5166
5295
  max,
5167
5296
  "aria-labelledby": label ? id : void 0,
5168
5297
  "aria-label": "Maximum percentage",
@@ -5237,6 +5366,7 @@ function FilterMenu(props) {
5237
5366
  filters,
5238
5367
  values,
5239
5368
  defaultValues,
5369
+ resetValues = {},
5240
5370
  onChange,
5241
5371
  onClose,
5242
5372
  useClear,
@@ -5262,11 +5392,11 @@ function FilterMenu(props) {
5262
5392
  onClose?.();
5263
5393
  }, [onChange, onClose, internalValues]);
5264
5394
  const handleClear = useCallback19(() => {
5265
- const clearedValues = defaultValues || {};
5395
+ const clearedValues = resetValues || {};
5266
5396
  setInternalValues(clearedValues);
5267
5397
  onChange?.(clearedValues);
5268
5398
  onClose?.();
5269
- }, [defaultValues, setInternalValues, onChange, onClose]);
5399
+ }, [resetValues, setInternalValues, onChange, onClose]);
5270
5400
  return /* @__PURE__ */ React37.createElement(
5271
5401
  ModalDialog,
5272
5402
  {
@@ -5317,7 +5447,7 @@ FilterMenu.displayName = "FilterMenu";
5317
5447
  // src/components/Uploader/Uploader.tsx
5318
5448
  import React38, {
5319
5449
  useCallback as useCallback20,
5320
- useEffect as useEffect7,
5450
+ useEffect as useEffect8,
5321
5451
  useMemo as useMemo12,
5322
5452
  useRef as useRef6,
5323
5453
  useState as useState10
@@ -5619,7 +5749,7 @@ var Uploader = React38.memo(
5619
5749
  onChange
5620
5750
  ]
5621
5751
  );
5622
- useEffect7(() => {
5752
+ useEffect8(() => {
5623
5753
  if (!dropZoneRef.current || disabled) {
5624
5754
  return;
5625
5755
  }
@@ -5667,7 +5797,7 @@ var Uploader = React38.memo(
5667
5797
  );
5668
5798
  return () => cleanup?.();
5669
5799
  }, [disabled, addFiles]);
5670
- useEffect7(() => {
5800
+ useEffect8(() => {
5671
5801
  if (inputRef.current && minCount) {
5672
5802
  if (files.length < minCount) {
5673
5803
  inputRef.current.setCustomValidity(
@@ -5832,14 +5962,14 @@ function IconMenuButton(props) {
5832
5962
  IconMenuButton.displayName = "IconMenuButton";
5833
5963
 
5834
5964
  // src/components/Markdown/Markdown.tsx
5835
- import React40, { lazy, Suspense, useEffect as useEffect8, useState as useState11 } from "react";
5965
+ import React40, { lazy, Suspense, useEffect as useEffect9, useState as useState11 } from "react";
5836
5966
  import { Skeleton } from "@mui/joy";
5837
5967
  import { Link as Link2 } from "@mui/joy";
5838
5968
  import remarkGfm from "remark-gfm";
5839
5969
  var LazyReactMarkdown = lazy(() => import("react-markdown"));
5840
5970
  var Markdown = (props) => {
5841
5971
  const [rehypeAccent2, setRehypeAccent] = useState11(null);
5842
- useEffect8(() => {
5972
+ useEffect9(() => {
5843
5973
  const loadRehypeAccent = async () => {
5844
5974
  const module = await Promise.resolve().then(() => (init_rehype_accent(), rehype_accent_exports));
5845
5975
  setRehypeAccent(() => module.rehypeAccent);
@@ -5978,7 +6108,7 @@ MenuButton.displayName = "MenuButton";
5978
6108
  import React42, {
5979
6109
  forwardRef as forwardRef9,
5980
6110
  useCallback as useCallback21,
5981
- useEffect as useEffect9,
6111
+ useEffect as useEffect10,
5982
6112
  useImperativeHandle as useImperativeHandle4,
5983
6113
  useRef as useRef7,
5984
6114
  useState as useState12
@@ -6095,7 +6225,7 @@ var MonthPicker = forwardRef9(
6095
6225
  );
6096
6226
  const [anchorEl, setAnchorEl] = useState12(null);
6097
6227
  const open = Boolean(anchorEl);
6098
- useEffect9(() => {
6228
+ useEffect10(() => {
6099
6229
  if (!anchorEl) {
6100
6230
  innerRef.current?.blur();
6101
6231
  }
@@ -6103,7 +6233,7 @@ var MonthPicker = forwardRef9(
6103
6233
  useImperativeHandle4(ref, () => innerRef.current, [
6104
6234
  innerRef
6105
6235
  ]);
6106
- useEffect9(() => {
6236
+ useEffect10(() => {
6107
6237
  setDisplayValue(getFormattedDisplayValue(value));
6108
6238
  }, [value, getFormattedDisplayValue]);
6109
6239
  const handleChange = useCallback21(
@@ -6251,7 +6381,7 @@ var MonthPicker = forwardRef9(
6251
6381
  import React43, {
6252
6382
  forwardRef as forwardRef10,
6253
6383
  useCallback as useCallback22,
6254
- useEffect as useEffect10,
6384
+ useEffect as useEffect11,
6255
6385
  useImperativeHandle as useImperativeHandle5,
6256
6386
  useMemo as useMemo13,
6257
6387
  useRef as useRef8,
@@ -6382,7 +6512,7 @@ var MonthRangePicker = forwardRef10(
6382
6512
  () => value ? parseDates2(value) : void 0,
6383
6513
  [value]
6384
6514
  );
6385
- useEffect10(() => {
6515
+ useEffect11(() => {
6386
6516
  if (!anchorEl) {
6387
6517
  innerRef.current?.blur();
6388
6518
  }