@ceed/ads 1.8.0-next.5 → 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/components/FilterMenu/types.d.ts +1 -1
- package/dist/index.cjs +38 -17
- package/dist/index.js +49 -28
- package/framer/index.js +36 -36
- package/package.json +1 -1
|
@@ -39,7 +39,7 @@ export interface FilterPercentageInputItem extends FilterBaseItem<number>, Pick<
|
|
|
39
39
|
export interface FilterPercentageRangeItem extends FilterBaseItem<[number, number]>, Pick<PercentageInputProps, "useMinorUnit" | "maxDecimalScale" | "min" | "max"> {
|
|
40
40
|
type: "percentage-range";
|
|
41
41
|
}
|
|
42
|
-
export interface FilterAutocompleteItem extends FilterBaseItem<string | number>, Pick<AutocompleteProps<any, boolean>, "options" | "multiple"> {
|
|
42
|
+
export interface FilterAutocompleteItem extends FilterBaseItem<string | number>, Pick<AutocompleteProps<any, boolean>, "options" | "multiple" | "placeholder"> {
|
|
43
43
|
type: "autocomplete";
|
|
44
44
|
}
|
|
45
45
|
export type FilterItem = FilterCheckboxGroupItem | FilterRadioGroupItem | FilterDateRangeItem | FilterCurrencyInputItem | FilterCurrencyRangeItem | FilterPercentageInputItem | FilterPercentageRangeItem | FilterAutocompleteItem;
|
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
|
|
4701
|
-
endOfMonth
|
|
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
|
|
4709
|
-
endOfYear
|
|
4714
|
+
formatDate(startOfYear),
|
|
4715
|
+
formatDate(endOfYear)
|
|
4710
4716
|
];
|
|
4711
4717
|
}
|
|
4712
4718
|
case "last-month": {
|
|
4713
|
-
const
|
|
4714
|
-
const
|
|
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
|
|
4717
|
-
endOfLastMonth
|
|
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;
|
|
@@ -5206,15 +5234,7 @@ PercentageRange.displayName = "PercentageRange";
|
|
|
5206
5234
|
var import_react38 = __toESM(require("react"));
|
|
5207
5235
|
var import_joy50 = require("@mui/joy");
|
|
5208
5236
|
function Autocomplete2(props) {
|
|
5209
|
-
const {
|
|
5210
|
-
id,
|
|
5211
|
-
label,
|
|
5212
|
-
value,
|
|
5213
|
-
onChange,
|
|
5214
|
-
options,
|
|
5215
|
-
multiple,
|
|
5216
|
-
hidden
|
|
5217
|
-
} = props;
|
|
5237
|
+
const { id, label, value, onChange, options, multiple, hidden, placeholder } = props;
|
|
5218
5238
|
const [internalValue, setInternalValue] = useControlledState(
|
|
5219
5239
|
value,
|
|
5220
5240
|
void 0,
|
|
@@ -5252,6 +5272,7 @@ function Autocomplete2(props) {
|
|
|
5252
5272
|
onChange: handleChange,
|
|
5253
5273
|
options,
|
|
5254
5274
|
multiple,
|
|
5275
|
+
placeholder,
|
|
5255
5276
|
"aria-labelledby": label ? id : void 0
|
|
5256
5277
|
}
|
|
5257
5278
|
));
|
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
|
|
4671
|
-
endOfMonth
|
|
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
|
|
4679
|
-
endOfYear
|
|
4684
|
+
formatDate(startOfYear),
|
|
4685
|
+
formatDate(endOfYear)
|
|
4680
4686
|
];
|
|
4681
4687
|
}
|
|
4682
4688
|
case "last-month": {
|
|
4683
|
-
const
|
|
4684
|
-
const
|
|
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
|
|
4687
|
-
endOfLastMonth
|
|
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;
|
|
@@ -5176,15 +5204,7 @@ PercentageRange.displayName = "PercentageRange";
|
|
|
5176
5204
|
import React36, { useCallback as useCallback18 } from "react";
|
|
5177
5205
|
import { Stack as Stack9 } from "@mui/joy";
|
|
5178
5206
|
function Autocomplete2(props) {
|
|
5179
|
-
const {
|
|
5180
|
-
id,
|
|
5181
|
-
label,
|
|
5182
|
-
value,
|
|
5183
|
-
onChange,
|
|
5184
|
-
options,
|
|
5185
|
-
multiple,
|
|
5186
|
-
hidden
|
|
5187
|
-
} = props;
|
|
5207
|
+
const { id, label, value, onChange, options, multiple, hidden, placeholder } = props;
|
|
5188
5208
|
const [internalValue, setInternalValue] = useControlledState(
|
|
5189
5209
|
value,
|
|
5190
5210
|
void 0,
|
|
@@ -5222,6 +5242,7 @@ function Autocomplete2(props) {
|
|
|
5222
5242
|
onChange: handleChange,
|
|
5223
5243
|
options,
|
|
5224
5244
|
multiple,
|
|
5245
|
+
placeholder,
|
|
5225
5246
|
"aria-labelledby": label ? id : void 0
|
|
5226
5247
|
}
|
|
5227
5248
|
));
|
|
@@ -5324,7 +5345,7 @@ FilterMenu.displayName = "FilterMenu";
|
|
|
5324
5345
|
// src/components/Uploader/Uploader.tsx
|
|
5325
5346
|
import React38, {
|
|
5326
5347
|
useCallback as useCallback20,
|
|
5327
|
-
useEffect as
|
|
5348
|
+
useEffect as useEffect8,
|
|
5328
5349
|
useMemo as useMemo12,
|
|
5329
5350
|
useRef as useRef6,
|
|
5330
5351
|
useState as useState10
|
|
@@ -5626,7 +5647,7 @@ var Uploader = React38.memo(
|
|
|
5626
5647
|
onChange
|
|
5627
5648
|
]
|
|
5628
5649
|
);
|
|
5629
|
-
|
|
5650
|
+
useEffect8(() => {
|
|
5630
5651
|
if (!dropZoneRef.current || disabled) {
|
|
5631
5652
|
return;
|
|
5632
5653
|
}
|
|
@@ -5674,7 +5695,7 @@ var Uploader = React38.memo(
|
|
|
5674
5695
|
);
|
|
5675
5696
|
return () => cleanup?.();
|
|
5676
5697
|
}, [disabled, addFiles]);
|
|
5677
|
-
|
|
5698
|
+
useEffect8(() => {
|
|
5678
5699
|
if (inputRef.current && minCount) {
|
|
5679
5700
|
if (files.length < minCount) {
|
|
5680
5701
|
inputRef.current.setCustomValidity(
|
|
@@ -5839,14 +5860,14 @@ function IconMenuButton(props) {
|
|
|
5839
5860
|
IconMenuButton.displayName = "IconMenuButton";
|
|
5840
5861
|
|
|
5841
5862
|
// src/components/Markdown/Markdown.tsx
|
|
5842
|
-
import React40, { lazy, Suspense, useEffect as
|
|
5863
|
+
import React40, { lazy, Suspense, useEffect as useEffect9, useState as useState11 } from "react";
|
|
5843
5864
|
import { Skeleton } from "@mui/joy";
|
|
5844
5865
|
import { Link as Link2 } from "@mui/joy";
|
|
5845
5866
|
import remarkGfm from "remark-gfm";
|
|
5846
5867
|
var LazyReactMarkdown = lazy(() => import("react-markdown"));
|
|
5847
5868
|
var Markdown = (props) => {
|
|
5848
5869
|
const [rehypeAccent2, setRehypeAccent] = useState11(null);
|
|
5849
|
-
|
|
5870
|
+
useEffect9(() => {
|
|
5850
5871
|
const loadRehypeAccent = async () => {
|
|
5851
5872
|
const module = await Promise.resolve().then(() => (init_rehype_accent(), rehype_accent_exports));
|
|
5852
5873
|
setRehypeAccent(() => module.rehypeAccent);
|
|
@@ -5985,7 +6006,7 @@ MenuButton.displayName = "MenuButton";
|
|
|
5985
6006
|
import React42, {
|
|
5986
6007
|
forwardRef as forwardRef9,
|
|
5987
6008
|
useCallback as useCallback21,
|
|
5988
|
-
useEffect as
|
|
6009
|
+
useEffect as useEffect10,
|
|
5989
6010
|
useImperativeHandle as useImperativeHandle4,
|
|
5990
6011
|
useRef as useRef7,
|
|
5991
6012
|
useState as useState12
|
|
@@ -6102,7 +6123,7 @@ var MonthPicker = forwardRef9(
|
|
|
6102
6123
|
);
|
|
6103
6124
|
const [anchorEl, setAnchorEl] = useState12(null);
|
|
6104
6125
|
const open = Boolean(anchorEl);
|
|
6105
|
-
|
|
6126
|
+
useEffect10(() => {
|
|
6106
6127
|
if (!anchorEl) {
|
|
6107
6128
|
innerRef.current?.blur();
|
|
6108
6129
|
}
|
|
@@ -6110,7 +6131,7 @@ var MonthPicker = forwardRef9(
|
|
|
6110
6131
|
useImperativeHandle4(ref, () => innerRef.current, [
|
|
6111
6132
|
innerRef
|
|
6112
6133
|
]);
|
|
6113
|
-
|
|
6134
|
+
useEffect10(() => {
|
|
6114
6135
|
setDisplayValue(getFormattedDisplayValue(value));
|
|
6115
6136
|
}, [value, getFormattedDisplayValue]);
|
|
6116
6137
|
const handleChange = useCallback21(
|
|
@@ -6258,7 +6279,7 @@ var MonthPicker = forwardRef9(
|
|
|
6258
6279
|
import React43, {
|
|
6259
6280
|
forwardRef as forwardRef10,
|
|
6260
6281
|
useCallback as useCallback22,
|
|
6261
|
-
useEffect as
|
|
6282
|
+
useEffect as useEffect11,
|
|
6262
6283
|
useImperativeHandle as useImperativeHandle5,
|
|
6263
6284
|
useMemo as useMemo13,
|
|
6264
6285
|
useRef as useRef8,
|
|
@@ -6389,7 +6410,7 @@ var MonthRangePicker = forwardRef10(
|
|
|
6389
6410
|
() => value ? parseDates2(value) : void 0,
|
|
6390
6411
|
[value]
|
|
6391
6412
|
);
|
|
6392
|
-
|
|
6413
|
+
useEffect11(() => {
|
|
6393
6414
|
if (!anchorEl) {
|
|
6394
6415
|
innerRef.current?.blur();
|
|
6395
6416
|
}
|