@mittwald/flow-react-components 0.2.0-alpha.801 → 0.2.0-alpha.803
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/CHANGELOG.md +10 -0
- package/dist/assets/doc-properties.json +799 -761
- package/dist/css/all.css +1 -1
- package/dist/js/@mittwald/password-tools-js.mjs +1 -1
- package/dist/js/_virtual/_.locale.json@aaaa2422dd023a875e13abc0d3d178ce.mjs +26 -0
- package/dist/js/_virtual/_.locale.json@aaaa2422dd023a875e13abc0d3d178ce.mjs.map +1 -0
- package/dist/js/flr-universal.mjs +5 -3
- package/dist/js/flr-universal.mjs.map +1 -1
- package/dist/js/packages/components/src/components/Calendar/Calendar.module.scss.mjs +5 -1
- package/dist/js/packages/components/src/components/Calendar/Calendar.module.scss.mjs.map +1 -1
- package/dist/js/packages/components/src/components/Calendar/components/RangeCalendar/RangeCalendar.mjs +40 -6
- package/dist/js/packages/components/src/components/Calendar/components/RangeCalendar/RangeCalendar.mjs.map +1 -1
- package/dist/js/packages/components/src/components/Calendar/components/RangeCalendar/helpers/useCalendarDateRangePresets.mjs +186 -0
- package/dist/js/packages/components/src/components/Calendar/components/RangeCalendar/helpers/useCalendarDateRangePresets.mjs.map +1 -0
- package/dist/js/packages/components/src/components/Calendar/components/RangeCalendar/types.mjs.map +1 -1
- package/dist/js/packages/components/src/components/DatePicker/DatePicker.mjs +10 -1
- package/dist/js/packages/components/src/components/DatePicker/DatePicker.mjs.map +1 -1
- package/dist/js/packages/components/src/components/DateRangePicker/DateRangePicker.mjs +24 -9
- package/dist/js/packages/components/src/components/DateRangePicker/DateRangePicker.mjs.map +1 -1
- package/dist/js/packages/components/src/components/Label/Label.mjs +4 -4
- package/dist/js/packages/components/src/components/Label/Label.mjs.map +1 -1
- package/dist/js/packages/components/src/components/Label/Label.module.scss.mjs +2 -2
- package/dist/js/packages/components/src/components/List/model/filter/DateRangeFilter.mjs +10 -0
- package/dist/js/packages/components/src/components/List/model/filter/DateRangeFilter.mjs.map +1 -1
- package/dist/js/packages/components/src/components/Switch/Switch.mjs +2 -2
- package/dist/js/packages/components/src/components/Switch/Switch.mjs.map +1 -1
- package/dist/types/components/Calendar/components/RangeCalendar/RangeCalendar.d.ts +2 -1
- package/dist/types/components/Calendar/components/RangeCalendar/RangeCalendar.d.ts.map +1 -1
- package/dist/types/components/Calendar/components/RangeCalendar/helpers/useCalendarDateRangePresets.d.ts +8 -0
- package/dist/types/components/Calendar/components/RangeCalendar/helpers/useCalendarDateRangePresets.d.ts.map +1 -0
- package/dist/types/components/Calendar/components/RangeCalendar/types.d.ts +1 -0
- package/dist/types/components/Calendar/components/RangeCalendar/types.d.ts.map +1 -1
- package/dist/types/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +2 -0
- package/dist/types/components/DateRangePicker/DateRangePicker.d.ts.map +1 -1
- package/dist/types/components/DateRangePicker/stories/Default.stories.d.ts +2 -0
- package/dist/types/components/DateRangePicker/stories/Default.stories.d.ts.map +1 -1
- package/dist/types/integrations/@mittwald/password-tools-js/index.d.ts +1 -1
- package/dist/types/integrations/@mittwald/password-tools-js/index.d.ts.map +1 -1
- package/package.json +7 -7
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
export { defaultPasswordCreationPolicy } from '../packages/components/src/integrations/@mittwald/password-tools-js/defaultPasswordCreationPolicy.mjs';
|
|
4
4
|
export { generatePasswordCreationFieldValidation, usePasswordCreationFieldValidation } from '../packages/components/src/integrations/@mittwald/password-tools-js/usePasswordCreationFieldValidation.mjs';
|
|
5
5
|
export { Policy } from '@mittwald/password-tools-js/policy';
|
|
6
|
-
export {
|
|
6
|
+
export { RegexFlags, Rule, RuleType, SequenceType } from '@mittwald/password-tools-js/rules';
|
|
7
7
|
export { Generator } from '@mittwald/password-tools-js/generator';
|
|
8
8
|
//# sourceMappingURL=password-tools-js.mjs.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
const locales = {"de-DE":{
|
|
4
|
+
"preset.lastMonth": "Letzten Monat",
|
|
5
|
+
"preset.lastWeek": "Letzte Woche",
|
|
6
|
+
"preset.lastYear": "Letztes Jahr",
|
|
7
|
+
"preset.thisMonth": "Diesen Monat",
|
|
8
|
+
"preset.thisWeek": "Diese Woche",
|
|
9
|
+
"preset.thisYear": "Dieses Jahr",
|
|
10
|
+
"preset.today": "Heute",
|
|
11
|
+
"preset.yesterday": "Gestern"
|
|
12
|
+
}
|
|
13
|
+
,"en-US":{
|
|
14
|
+
"preset.lastMonth": "Last month",
|
|
15
|
+
"preset.lastWeek": "Last week",
|
|
16
|
+
"preset.lastYear": "Last year",
|
|
17
|
+
"preset.thisMonth": "This month",
|
|
18
|
+
"preset.thisWeek": "This week",
|
|
19
|
+
"preset.thisYear": "This year",
|
|
20
|
+
"preset.today": "Today",
|
|
21
|
+
"preset.yesterday": "Yesterday"
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { locales as default };
|
|
26
|
+
//# sourceMappingURL=_.locale.json@aaaa2422dd023a875e13abc0d3d178ce.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_.locale.json@aaaa2422dd023a875e13abc0d3d178ce.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -158,6 +158,11 @@ export { Wrap } from './packages/components/src/components/Wrap/Wrap.mjs';
|
|
|
158
158
|
import './packages/components/src/components/Badge/Badge.mjs';
|
|
159
159
|
import 'react-aria-components';
|
|
160
160
|
export { BrowserOnly } from './packages/components/src/components/BrowserOnly/BrowserOnly.mjs';
|
|
161
|
+
import './packages/components/src/components/MenuItem/MenuItem.mjs';
|
|
162
|
+
import 'luxon';
|
|
163
|
+
import '@internationalized/date';
|
|
164
|
+
import 'invariant';
|
|
165
|
+
import 'usehooks-ts';
|
|
161
166
|
import 'recharts';
|
|
162
167
|
import 'use-callback-ref';
|
|
163
168
|
import './packages/components/src/views/DivView.mjs';
|
|
@@ -179,7 +184,6 @@ import './packages/components/src/components/ComboBox/ComboBox.mjs';
|
|
|
179
184
|
import './packages/components/src/lib/propsContext/components/ComponentPropsContextProvider.mjs';
|
|
180
185
|
import './packages/components/src/components/Content/Content.mjs';
|
|
181
186
|
import './packages/components/src/components/ContextMenu/ContextMenu.mjs';
|
|
182
|
-
import './packages/components/src/components/MenuItem/MenuItem.mjs';
|
|
183
187
|
import './packages/components/src/components/ContextMenu/components/ContextMenuTrigger/ContextMenuTrigger.mjs';
|
|
184
188
|
import './packages/components/src/components/ContextMenu/components/ContextMenuSection/ContextMenuSection.mjs';
|
|
185
189
|
import './packages/components/src/components/ContextualHelp/ContextualHelp.mjs';
|
|
@@ -209,7 +213,6 @@ import './packages/components/src/components/LayoutCard/LayoutCard.mjs';
|
|
|
209
213
|
export { LightBoxTrigger } from './packages/components/src/components/LightBox/components/LightBoxTrigger/LightBoxTrigger.mjs';
|
|
210
214
|
export { LightBox } from './packages/components/src/components/LightBox/LightBox.mjs';
|
|
211
215
|
import './packages/components/src/components/Link/Link.mjs';
|
|
212
|
-
import 'invariant';
|
|
213
216
|
export { ListItemView } from './packages/components/src/components/List/components/ListItemView/ListItemView.mjs';
|
|
214
217
|
import './packages/components/src/components/List/components/ListSummary/ListSummary.mjs';
|
|
215
218
|
import './packages/components/src/components/List/listContext.mjs';
|
|
@@ -226,7 +229,6 @@ export { Modal } from './packages/components/src/components/Modal/Modal.mjs';
|
|
|
226
229
|
import './packages/components/src/components/Navigation/Navigation.mjs';
|
|
227
230
|
import './packages/components/src/components/Navigation/components/NavigationGroup/NavigationGroup.mjs';
|
|
228
231
|
export { NotificationProvider, useNotificationController } from './packages/components/src/components/NotificationProvider/NotificationProvider.mjs';
|
|
229
|
-
import 'luxon';
|
|
230
232
|
import './packages/components/src/components/NumberField/NumberField.mjs';
|
|
231
233
|
import './packages/components/src/components/Option/Option.mjs';
|
|
232
234
|
export { OverlayController } from './packages/components/src/lib/controller/overlay/OverlayController.mjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flr-universal.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"flr-universal.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
3
|
const calendar = "flow--calendar";
|
|
4
|
+
const container = "flow--calendar--container";
|
|
5
|
+
const presetMenu = "flow--calendar--preset-menu";
|
|
4
6
|
const range = "flow--calendar--range";
|
|
5
7
|
const styles = {
|
|
6
8
|
calendar: calendar,
|
|
9
|
+
container: container,
|
|
10
|
+
presetMenu: presetMenu,
|
|
7
11
|
range: range
|
|
8
12
|
};
|
|
9
13
|
|
|
10
|
-
export { calendar, styles as default, range };
|
|
14
|
+
export { calendar, container, styles as default, presetMenu, range };
|
|
11
15
|
//# sourceMappingURL=Calendar.module.scss.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.module.scss.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Calendar.module.scss.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
|
|
@@ -1,19 +1,53 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
import { jsxs,
|
|
3
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import 'react';
|
|
5
5
|
import * as Aria from 'react-aria-components';
|
|
6
6
|
import styles from '../../Calendar.module.scss.mjs';
|
|
7
7
|
import { CalendarHeader } from '../CalendarHeader/CalendarHeader.mjs';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
|
+
import { MenuItem } from '../../../MenuItem/MenuItem.mjs';
|
|
10
|
+
import { useCalendarDateRangePresets } from './helpers/useCalendarDateRangePresets.mjs';
|
|
11
|
+
import { Separator } from '../../../Separator/Separator.mjs';
|
|
12
|
+
import { useMediaQuery } from 'usehooks-ts';
|
|
9
13
|
|
|
14
|
+
const InnerRangeCalendar = ({
|
|
15
|
+
withDatePickerPresets
|
|
16
|
+
}) => {
|
|
17
|
+
const isSmallViewport = useMediaQuery("(max-width: 530px)");
|
|
18
|
+
const dateRangeHelper = useCalendarDateRangePresets(withDatePickerPresets);
|
|
19
|
+
const predefinedDateHelperItems = dateRangeHelper.map((present) => {
|
|
20
|
+
return /* @__PURE__ */ jsx(
|
|
21
|
+
MenuItem,
|
|
22
|
+
{
|
|
23
|
+
isDisabled: present.disabled,
|
|
24
|
+
onPress: present.onPress,
|
|
25
|
+
"aria-label": present.label,
|
|
26
|
+
children: present.label
|
|
27
|
+
},
|
|
28
|
+
present.label
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
return /* @__PURE__ */ jsxs("div", { className: styles.container, children: [
|
|
32
|
+
withDatePickerPresets && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
33
|
+
/* @__PURE__ */ jsx(Aria.Menu, { className: styles.presetMenu, children: predefinedDateHelperItems }),
|
|
34
|
+
/* @__PURE__ */ jsx(
|
|
35
|
+
Separator,
|
|
36
|
+
{
|
|
37
|
+
orientation: isSmallViewport ? "horizontal" : "vertical"
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
] }),
|
|
41
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
42
|
+
/* @__PURE__ */ jsx(CalendarHeader, {}),
|
|
43
|
+
/* @__PURE__ */ jsx(Aria.CalendarGrid, { children: (date) => /* @__PURE__ */ jsx(Aria.CalendarCell, { date }) })
|
|
44
|
+
] })
|
|
45
|
+
] });
|
|
46
|
+
};
|
|
10
47
|
const RangeCalendar = (props) => {
|
|
11
|
-
const { className, ...rest } = props;
|
|
48
|
+
const { className, withDatePickerPresets, ...rest } = props;
|
|
12
49
|
const rootClassName = clsx(styles.calendar, styles.range, className);
|
|
13
|
-
return /* @__PURE__ */
|
|
14
|
-
/* @__PURE__ */ jsx(CalendarHeader, {}),
|
|
15
|
-
/* @__PURE__ */ jsx(Aria.CalendarGrid, { children: (date) => /* @__PURE__ */ jsx(Aria.CalendarCell, { date }) })
|
|
16
|
-
] });
|
|
50
|
+
return /* @__PURE__ */ jsx(Aria.RangeCalendar, { ...rest, className: rootClassName, children: /* @__PURE__ */ jsx(InnerRangeCalendar, { withDatePickerPresets }) });
|
|
17
51
|
};
|
|
18
52
|
|
|
19
53
|
export { RangeCalendar };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RangeCalendar.mjs","sources":["../../../../../../../../../src/components/Calendar/components/RangeCalendar/RangeCalendar.tsx"],"sourcesContent":["import React, { type FC } from \"react\";\nimport * as Aria from \"react-aria-components\";\nimport styles from \"@/components/Calendar/Calendar.module.scss\";\nimport CalendarHeader from \"../CalendarHeader\";\nimport clsx from \"clsx\";\n\nexport type RangeCalendarProps = Omit<\n Aria.RangeCalendarProps<Aria.DateValue>,\n \"children\"\n>;\n\n/** @
|
|
1
|
+
{"version":3,"file":"RangeCalendar.mjs","sources":["../../../../../../../../../src/components/Calendar/components/RangeCalendar/RangeCalendar.tsx"],"sourcesContent":["import React, { type FC } from \"react\";\nimport * as Aria from \"react-aria-components\";\nimport styles from \"@/components/Calendar/Calendar.module.scss\";\nimport CalendarHeader from \"../CalendarHeader\";\nimport clsx from \"clsx\";\nimport { MenuItem } from \"@/components/MenuItem\";\nimport { useCalendarDateRangePresets } from \"@/components/Calendar/components/RangeCalendar/helpers/useCalendarDateRangePresets\";\nimport { Separator } from \"@/components/Separator\";\nimport { useMediaQuery } from \"usehooks-ts\";\nimport type { DateRangePickerProps } from \"@/components/DateRangePicker\";\n\nexport type RangeCalendarProps = Omit<\n Aria.RangeCalendarProps<Aria.DateValue>,\n \"children\"\n> &\n Pick<DateRangePickerProps, \"withDatePickerPresets\">;\n\n/** @internal */\nconst InnerRangeCalendar: FC<RangeCalendarProps> = ({\n withDatePickerPresets,\n}) => {\n const isSmallViewport = useMediaQuery(\"(max-width: 530px)\");\n const dateRangeHelper = useCalendarDateRangePresets(withDatePickerPresets);\n\n const predefinedDateHelperItems = dateRangeHelper.map((present) => {\n return (\n <MenuItem\n key={present.label}\n isDisabled={present.disabled}\n onPress={present.onPress}\n aria-label={present.label}\n >\n {present.label}\n </MenuItem>\n );\n });\n\n return (\n <div className={styles.container}>\n {withDatePickerPresets && (\n <>\n <Aria.Menu className={styles.presetMenu}>\n {predefinedDateHelperItems}\n </Aria.Menu>\n <Separator\n orientation={isSmallViewport ? \"horizontal\" : \"vertical\"}\n />\n </>\n )}\n <div>\n <CalendarHeader />\n <Aria.CalendarGrid>\n {(date) => <Aria.CalendarCell date={date} />}\n </Aria.CalendarGrid>\n </div>\n </div>\n );\n};\n\n/** @flr-generate all */\nexport const RangeCalendar: FC<RangeCalendarProps> = (props) => {\n const { className, withDatePickerPresets, ...rest } = props;\n const rootClassName = clsx(styles.calendar, styles.range, className);\n\n return (\n <Aria.RangeCalendar {...rest} className={rootClassName}>\n <InnerRangeCalendar withDatePickerPresets={withDatePickerPresets} />\n </Aria.RangeCalendar>\n );\n};\n\nexport default RangeCalendar;\n"],"names":[],"mappings":";;;;;;;;;;;AAkBA,MAAM,qBAA6C,CAAC;AAAA,EAClD;AACF,CAAA,KAAM;AACJ,EAAA,MAAM,eAAA,GAAkB,cAAc,oBAAoB,CAAA;AAC1D,E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AM,gBAAgB,IAAA,CAAK,MAAA,CAAO,QAAA,EAAU,MAAA,CAAO,OAAO,SAAS,CAAA;AAEnE,EAAA,uBACE,GAAA,CAAC,IAAA,CAAK,aAAA,EAAL,EAAoB,GAAG,IAAA,EAAM,SAAA,EAAW,aAAA,EACvC,QAAA,kBAAA,GAAA,CAAC,kBAAA,EAAA,EAAmB,qBAAA,EAA8C,CAAA,EACpE,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
import { DateTime } from 'luxon';
|
|
4
|
+
import { toCalendarDate, CalendarDate } from '@internationalized/date';
|
|
5
|
+
import { useContext, useMemo } from 'react';
|
|
6
|
+
import { RangeCalendarStateContext } from 'react-aria-components';
|
|
7
|
+
import '../../../../TranslationProvider/TranslationProvider.mjs';
|
|
8
|
+
import { useLocalizedStringFormatter } from '../../../../TranslationProvider/useLocalizedStringFormatter.mjs';
|
|
9
|
+
import locales from '../../../../../../../../_virtual/_.locale.json@aaaa2422dd023a875e13abc0d3d178ce.mjs';
|
|
10
|
+
import invariant from 'invariant';
|
|
11
|
+
|
|
12
|
+
const clampCalendarDate = (date, minDate, maxDate) => {
|
|
13
|
+
if (minDate && date.compare(minDate) < 0) {
|
|
14
|
+
return minDate;
|
|
15
|
+
}
|
|
16
|
+
if (maxDate && date.compare(maxDate) > 0) {
|
|
17
|
+
return maxDate;
|
|
18
|
+
}
|
|
19
|
+
return date;
|
|
20
|
+
};
|
|
21
|
+
const clampCalendarDateRange = (startDate, endDate, minDate, maxDate) => {
|
|
22
|
+
const clampedStart = clampCalendarDate(startDate, minDate, maxDate);
|
|
23
|
+
const clampedEnd = clampCalendarDate(endDate, minDate, maxDate);
|
|
24
|
+
return {
|
|
25
|
+
start: clampedStart,
|
|
26
|
+
end: clampedEnd,
|
|
27
|
+
invalid: clampedStart.compare(clampedEnd) > 0
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
const useCalendarDateRangePresets = (customPresets) => {
|
|
31
|
+
const now = DateTime.local();
|
|
32
|
+
const state = useContext(RangeCalendarStateContext);
|
|
33
|
+
const stringFormatter = useLocalizedStringFormatter(locales, "Calendar");
|
|
34
|
+
invariant(!!state, "Could not find RangeCalendarStateContext.");
|
|
35
|
+
const minDate = state.minValue ? toCalendarDate(state.minValue) : void 0;
|
|
36
|
+
const maxDate = state.maxValue ? toCalendarDate(state.maxValue) : void 0;
|
|
37
|
+
const isValidRange = (range) => !state.isInvalid(range.start) && !state.isInvalid(range.end);
|
|
38
|
+
const possibleRanges = useMemo(() => {
|
|
39
|
+
if (typeof customPresets !== "boolean") {
|
|
40
|
+
return customPresets ?? [];
|
|
41
|
+
}
|
|
42
|
+
const todayDate = new CalendarDate(now.year, now.month, now.day);
|
|
43
|
+
const yesterdayLuxon = now.minus({ days: 1 });
|
|
44
|
+
const yesterdayDate = new CalendarDate(
|
|
45
|
+
yesterdayLuxon.year,
|
|
46
|
+
yesterdayLuxon.month,
|
|
47
|
+
yesterdayLuxon.day
|
|
48
|
+
);
|
|
49
|
+
const thisWeekStart = now.startOf("week");
|
|
50
|
+
const thisWeekEnd = now.endOf("week");
|
|
51
|
+
const lastWeekLuxon = now.minus({ week: 1 });
|
|
52
|
+
const lastWeekStart = lastWeekLuxon.startOf("week");
|
|
53
|
+
const lastWeekEnd = lastWeekLuxon.endOf("week");
|
|
54
|
+
const thisMonthStart = now.startOf("month");
|
|
55
|
+
const thisMonthEnd = now.endOf("month");
|
|
56
|
+
const lastMonthLuxon = now.minus({ month: 1 });
|
|
57
|
+
const lastMonthStart = lastMonthLuxon.startOf("month");
|
|
58
|
+
const lastMonthEnd = lastMonthLuxon.endOf("month");
|
|
59
|
+
const thisYearStart = now.startOf("year");
|
|
60
|
+
const thisYearEnd = now.endOf("year");
|
|
61
|
+
const lastYearLuxon = now.minus({ year: 1 });
|
|
62
|
+
const lastYearStart = lastYearLuxon.startOf("year");
|
|
63
|
+
const lastYearEnd = lastYearLuxon.endOf("year");
|
|
64
|
+
return [
|
|
65
|
+
{
|
|
66
|
+
label: stringFormatter.format("preset.today"),
|
|
67
|
+
start: todayDate,
|
|
68
|
+
end: todayDate
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
label: stringFormatter.format("preset.yesterday"),
|
|
72
|
+
start: yesterdayDate,
|
|
73
|
+
end: yesterdayDate
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
label: stringFormatter.format("preset.thisWeek"),
|
|
77
|
+
start: new CalendarDate(
|
|
78
|
+
thisWeekStart.year,
|
|
79
|
+
thisWeekStart.month,
|
|
80
|
+
thisWeekStart.day
|
|
81
|
+
),
|
|
82
|
+
end: new CalendarDate(
|
|
83
|
+
thisWeekEnd.year,
|
|
84
|
+
thisWeekEnd.month,
|
|
85
|
+
thisWeekEnd.day
|
|
86
|
+
)
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
label: stringFormatter.format("preset.lastWeek"),
|
|
90
|
+
start: new CalendarDate(
|
|
91
|
+
lastWeekStart.year,
|
|
92
|
+
lastWeekStart.month,
|
|
93
|
+
lastWeekStart.day
|
|
94
|
+
),
|
|
95
|
+
end: new CalendarDate(
|
|
96
|
+
lastWeekEnd.year,
|
|
97
|
+
lastWeekEnd.month,
|
|
98
|
+
lastWeekEnd.day
|
|
99
|
+
)
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
label: stringFormatter.format("preset.thisMonth"),
|
|
103
|
+
start: new CalendarDate(
|
|
104
|
+
thisMonthStart.year,
|
|
105
|
+
thisMonthStart.month,
|
|
106
|
+
thisMonthStart.day
|
|
107
|
+
),
|
|
108
|
+
end: new CalendarDate(
|
|
109
|
+
thisMonthEnd.year,
|
|
110
|
+
thisMonthEnd.month,
|
|
111
|
+
thisMonthEnd.day
|
|
112
|
+
)
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
label: stringFormatter.format("preset.lastMonth"),
|
|
116
|
+
start: new CalendarDate(
|
|
117
|
+
lastMonthStart.year,
|
|
118
|
+
lastMonthStart.month,
|
|
119
|
+
lastMonthStart.day
|
|
120
|
+
),
|
|
121
|
+
end: new CalendarDate(
|
|
122
|
+
lastMonthEnd.year,
|
|
123
|
+
lastMonthEnd.month,
|
|
124
|
+
lastMonthEnd.day
|
|
125
|
+
)
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
label: stringFormatter.format("preset.thisYear"),
|
|
129
|
+
start: new CalendarDate(
|
|
130
|
+
thisYearStart.year,
|
|
131
|
+
thisYearStart.month,
|
|
132
|
+
thisYearStart.day
|
|
133
|
+
),
|
|
134
|
+
end: new CalendarDate(
|
|
135
|
+
thisYearEnd.year,
|
|
136
|
+
thisYearEnd.month,
|
|
137
|
+
thisYearEnd.day
|
|
138
|
+
)
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
label: stringFormatter.format("preset.lastYear"),
|
|
142
|
+
start: new CalendarDate(
|
|
143
|
+
lastYearStart.year,
|
|
144
|
+
lastYearStart.month,
|
|
145
|
+
lastYearStart.day
|
|
146
|
+
),
|
|
147
|
+
end: new CalendarDate(
|
|
148
|
+
lastYearEnd.year,
|
|
149
|
+
lastYearEnd.month,
|
|
150
|
+
lastYearEnd.day
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
];
|
|
154
|
+
}, [now, customPresets, stringFormatter]);
|
|
155
|
+
return possibleRanges.map((range) => {
|
|
156
|
+
if (minDate && range.end.compare(minDate) < 0 || maxDate && range.start.compare(maxDate) > 0) {
|
|
157
|
+
return {
|
|
158
|
+
...range,
|
|
159
|
+
disabled: true,
|
|
160
|
+
onPress: () => {
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
const { start, end, invalid } = clampCalendarDateRange(
|
|
165
|
+
range.start,
|
|
166
|
+
range.end,
|
|
167
|
+
minDate,
|
|
168
|
+
maxDate
|
|
169
|
+
);
|
|
170
|
+
const presetDisabled = invalid || !isValidRange({ start, end });
|
|
171
|
+
return {
|
|
172
|
+
...range,
|
|
173
|
+
start,
|
|
174
|
+
end,
|
|
175
|
+
disabled: presetDisabled,
|
|
176
|
+
onPress: () => {
|
|
177
|
+
if (!presetDisabled) {
|
|
178
|
+
state.setValue({ start, end });
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export { useCalendarDateRangePresets };
|
|
186
|
+
//# sourceMappingURL=useCalendarDateRangePresets.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCalendarDateRangePresets.mjs","sources":["../../../../../../../../../../src/components/Calendar/components/RangeCalendar/helpers/useCalendarDateRangePresets.ts"],"sourcesContent":["import { DateTime } from \"luxon\";\nimport { CalendarDate, toCalendarDate } from \"@internationalized/date\";\nimport { useContext, useMemo } from \"react\";\nimport { RangeCalendarStateContext } from \"react-aria-components\";\nimport { useLocalizedStringFormatter } from \"@/components/TranslationProvider\";\nimport locales from \"../../../locales/*.locale.json\";\nimport invariant from \"invariant\";\n\nexport interface DateRangePresetItem {\n start: CalendarDate;\n end: CalendarDate;\n label: string;\n}\n\nexport type DateRangePresets = DateRangePresetItem[];\n\ninterface CalendarDateRangePresetItem extends DateRangePresetItem {\n onPress: () => void;\n disabled: boolean;\n}\n\nconst clampCalendarDate = (\n date: CalendarDate,\n minDate?: CalendarDate,\n maxDate?: CalendarDate,\n) => {\n if (minDate && date.compare(minDate) < 0) {\n return minDate;\n }\n\n if (maxDate && date.compare(maxDate) > 0) {\n return maxDate;\n }\n\n return date;\n};\n\nconst clampCalendarDateRange = (\n startDate: CalendarDate,\n endDate: CalendarDate,\n minDate?: CalendarDate,\n maxDate?: CalendarDate,\n) => {\n const clampedStart = clampCalendarDate(startDate, minDate, maxDate);\n const clampedEnd = clampCalendarDate(endDate, minDate, maxDate);\n\n return {\n start: clampedStart,\n end: clampedEnd,\n invalid: clampedStart.compare(clampedEnd) > 0,\n };\n};\n\n/** @internal * */\nexport const useCalendarDateRangePresets = (\n customPresets?: DateRangePresets | boolean,\n): CalendarDateRangePresetItem[] => {\n const now = DateTime.local();\n const state = useContext(RangeCalendarStateContext);\n const stringFormatter = useLocalizedStringFormatter(locales, \"Calendar\");\n\n invariant(!!state, \"Could not find RangeCalendarStateContext.\");\n\n const minDate = state.minValue ? toCalendarDate(state.minValue) : undefined;\n const maxDate = state.maxValue ? toCalendarDate(state.maxValue) : undefined;\n\n const isValidRange = (range: { start: CalendarDate; end: CalendarDate }) =>\n !state.isInvalid(range.start) && !state.isInvalid(range.end);\n\n const possibleRanges = useMemo<DateRangePresets>(() => {\n if (typeof customPresets !== \"boolean\") {\n return customPresets ?? [];\n }\n\n const todayDate = new CalendarDate(now.year, now.month, now.day);\n const yesterdayLuxon = now.minus({ days: 1 });\n const yesterdayDate = new CalendarDate(\n yesterdayLuxon.year,\n yesterdayLuxon.month,\n yesterdayLuxon.day,\n );\n\n const thisWeekStart = now.startOf(\"week\");\n const thisWeekEnd = now.endOf(\"week\");\n const lastWeekLuxon = now.minus({ week: 1 });\n const lastWeekStart = lastWeekLuxon.startOf(\"week\");\n const lastWeekEnd = lastWeekLuxon.endOf(\"week\");\n\n const thisMonthStart = now.startOf(\"month\");\n const thisMonthEnd = now.endOf(\"month\");\n const lastMonthLuxon = now.minus({ month: 1 });\n const lastMonthStart = lastMonthLuxon.startOf(\"month\");\n const lastMonthEnd = lastMonthLuxon.endOf(\"month\");\n\n const thisYearStart = now.startOf(\"year\");\n const thisYearEnd = now.endOf(\"year\");\n const lastYearLuxon = now.minus({ year: 1 });\n const lastYearStart = lastYearLuxon.startOf(\"year\");\n const lastYearEnd = lastYearLuxon.endOf(\"year\");\n\n return [\n {\n label: stringFormatter.format(\"preset.today\"),\n start: todayDate,\n end: todayDate,\n },\n {\n label: stringFormatter.format(\"preset.yesterday\"),\n start: yesterdayDate,\n end: yesterdayDate,\n },\n {\n label: stringFormatter.format(\"preset.thisWeek\"),\n start: new CalendarDate(\n thisWeekStart.year,\n thisWeekStart.month,\n thisWeekStart.day,\n ),\n end: new CalendarDate(\n thisWeekEnd.year,\n thisWeekEnd.month,\n thisWeekEnd.day,\n ),\n },\n {\n label: stringFormatter.format(\"preset.lastWeek\"),\n start: new CalendarDate(\n lastWeekStart.year,\n lastWeekStart.month,\n lastWeekStart.day,\n ),\n end: new CalendarDate(\n lastWeekEnd.year,\n lastWeekEnd.month,\n lastWeekEnd.day,\n ),\n },\n {\n label: stringFormatter.format(\"preset.thisMonth\"),\n start: new CalendarDate(\n thisMonthStart.year,\n thisMonthStart.month,\n thisMonthStart.day,\n ),\n end: new CalendarDate(\n thisMonthEnd.year,\n thisMonthEnd.month,\n thisMonthEnd.day,\n ),\n },\n {\n label: stringFormatter.format(\"preset.lastMonth\"),\n start: new CalendarDate(\n lastMonthStart.year,\n lastMonthStart.month,\n lastMonthStart.day,\n ),\n end: new CalendarDate(\n lastMonthEnd.year,\n lastMonthEnd.month,\n lastMonthEnd.day,\n ),\n },\n {\n label: stringFormatter.format(\"preset.thisYear\"),\n start: new CalendarDate(\n thisYearStart.year,\n thisYearStart.month,\n thisYearStart.day,\n ),\n end: new CalendarDate(\n thisYearEnd.year,\n thisYearEnd.month,\n thisYearEnd.day,\n ),\n },\n {\n label: stringFormatter.format(\"preset.lastYear\"),\n start: new CalendarDate(\n lastYearStart.year,\n lastYearStart.month,\n lastYearStart.day,\n ),\n end: new CalendarDate(\n lastYearEnd.year,\n lastYearEnd.month,\n lastYearEnd.day,\n ),\n },\n ];\n }, [now, customPresets, stringFormatter]);\n\n return possibleRanges.map((range) => {\n if (\n (minDate && range.end.compare(minDate) < 0) ||\n (maxDate && range.start.compare(maxDate) > 0)\n ) {\n return {\n ...range,\n disabled: true,\n onPress: () => {\n // void\n },\n };\n }\n\n const { start, end, invalid } = clampCalendarDateRange(\n range.start,\n range.end,\n minDate,\n maxDate,\n );\n\n const presetDisabled = invalid || !isValidRange({ start, end });\n\n return {\n ...range,\n start,\n end,\n disabled: presetDisabled,\n onPress: () => {\n if (!presetDisabled) {\n state.setValue({ start, end });\n }\n },\n };\n });\n};\n"],"names":[],"mappings":";;;;;;;;;AAqBA,MAAM,iBAAA,GAAoB,CACxB,IAAA,EACA,OAAA,EACA,OAAA,KACG;AACH,EAAA,IAAI,OAAA,IAAW,IAAA,CAAK,OAAA,CAAQ,OAAO,IAAI,CAAA,EAAG;AACxC,IAAA,OAAO,OAAA;AAAA,EACT;AAEA,EAAA,IAAI,OAAA,IAAW,IAAA,CAAK,OAAA,CAAQ,OAAO,IAAI,CAAA,EAAG;AACxC,IAAA,OAAO,OAAA;AAAA,EACT;AAEA,EAAA,OAAO,IAAA;AACT,CAAA;AAEA,MAAM,sBAAA,GAAyB,CAC7B,SAAA,EACA,OAAA,EACA,SACA,OAAA,KACG;AACH,EAAA,MAAM,YAAA,GAAe,iBAAA,CAAkB,SAAA,EAAW,OAAA,EAAS,OAAO,CAAA;AAClE,EAAA,MAAM,UAAA,GAAa,iBAAA,CAAkB,OAAA,EAAS,OAAA,EAAS,OAAO,CAAA;AAE9D,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,YAAA;AAAA,IACP,GAAA,EAAK,UAAA;AAAA,IACL,OAAA,EAAS,YAAA,CAAa,OAAA,CAAQ,UAAU,CAAA,GAAI;AAAA,GAC9C;AACF,CAAA;AAGO,MAAM,2BAAA,GAA8B,CACzC,aAAA,KACkC;AAClC,EAAA,MAAM,GAAA,GAAM,SAAS,KAAA,EAAM;AAC3B,EAAA,MAAM,KAAA,GAAQ,WAAW,yBAAyB,CAAA;AAClD,EAAA,MAAM,eAAA,GAAkB,2BAAA,CAA4B,OAAA,EAAS,UAAU,CAAA;AAEvE,EAAA,SAAA,CAAU,CAAC,CAAC,KAAA,EAAO,2CAA2C,CAAA;AAE9D,EAAA,MAAM,UAAU,KAAA,CAAM,QAAA,GAAW,cAAA,CAAe,KAAA,CAAM,QAAQ,CAAA,GAAI,MAAA;AAClE,EAAA,MAAM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,MACF;AAAA,KACF;AAAA,EACF,CAAC,CAAA;AACH;;;;"}
|
package/dist/js/packages/components/src/components/Calendar/components/RangeCalendar/types.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sources":["../../../../../../../../../src/components/Calendar/components/RangeCalendar/types.ts"],"sourcesContent":["import type { DateRange } from \"react-aria-components\";\n\nexport function isDateRangeValue(value: unknown): value is DateRange {\n return !!(\n value &&\n typeof value === \"object\" &&\n \"start\" in value &&\n \"end\" in value\n );\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.mjs","sources":["../../../../../../../../../src/components/Calendar/components/RangeCalendar/types.ts"],"sourcesContent":["import type { DateRange } from \"react-aria-components\";\n\nexport type {\n DateRangePresets,\n DateRangePresetItem,\n} from \"./helpers/useCalendarDateRangePresets\";\n\nexport function isDateRangeValue(value: unknown): value is DateRange {\n return !!(\n value &&\n typeof value === \"object\" &&\n \"start\" in value &&\n \"end\" in value\n );\n}\n"],"names":[],"mappings":"AAOO,SAAS,iBAAiB,KAAA,EAAoC;AACnE,EAAA,OAAO,CAAC,EACN,KAAA,IACA,OAAO,UAAU,QAAA,IACjB,OAAA,IAAW,SACX,KAAA,IAAS,KAAA,CAAA;AAEb;;;;"}
|
|
@@ -20,11 +20,21 @@ import '@mittwald/flow-icons';
|
|
|
20
20
|
import '../Icon/components/IconSetProvider.mjs';
|
|
21
21
|
import '../Icon/Icon.mjs';
|
|
22
22
|
import '../../views/IconView.mjs';
|
|
23
|
+
import '../MenuItem/MenuItem.mjs';
|
|
24
|
+
import 'luxon';
|
|
25
|
+
import '@internationalized/date';
|
|
26
|
+
import '../TranslationProvider/TranslationProvider.mjs';
|
|
27
|
+
import 'intl-messageformat';
|
|
28
|
+
import '@react-aria/i18n';
|
|
29
|
+
import 'react-aria';
|
|
30
|
+
import 'invariant';
|
|
31
|
+
import 'usehooks-ts';
|
|
23
32
|
import { useFieldComponent } from '../../lib/hooks/useFieldComponent.mjs';
|
|
24
33
|
import styles from './DatePicker.module.scss.mjs';
|
|
25
34
|
|
|
26
35
|
const DatePicker = flowComponent("DatePicker", (props) => {
|
|
27
36
|
const { children, className, onChange, ref, ...rest } = props;
|
|
37
|
+
const popoverController = useOverlayController("Popover");
|
|
28
38
|
const {
|
|
29
39
|
FieldErrorView,
|
|
30
40
|
FieldErrorCaptureContext,
|
|
@@ -32,7 +42,6 @@ const DatePicker = flowComponent("DatePicker", (props) => {
|
|
|
32
42
|
fieldPropsContext
|
|
33
43
|
} = useFieldComponent(props);
|
|
34
44
|
const rootClassName = clsx(fieldProps.className, className);
|
|
35
|
-
const popoverController = useOverlayController("Popover");
|
|
36
45
|
return /* @__PURE__ */ jsxs(
|
|
37
46
|
Aria.DatePicker,
|
|
38
47
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.mjs","sources":["../../../../../../../src/components/DatePicker/DatePicker.tsx"],"sourcesContent":["import { type PropsWithChildren } from \"react\";\nimport clsx from \"clsx\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport * as Aria from \"react-aria-components\";\nimport { DateInput } from \"./components/DateInput\";\nimport { Popover } from \"@/components/Popover/Popover\";\nimport { useOverlayController } from \"@/lib/controller\";\nimport {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport { Calendar } from \"@/components/Calendar\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\nimport styles from \"./DatePicker.module.scss\";\n\nexport interface DatePickerProps<T extends Aria.DateValue = Aria.DateValue>\n extends\n PropsWithChildren<Omit<Aria.DatePickerProps<T>, \"children\" | \"ref\">>,\n FlowComponentProps<HTMLSpanElement> {}\n\n/** @flr-generate all */\nexport const DatePicker = flowComponent(\"DatePicker\", (props) => {\n const { children, className, onChange, ref, ...rest } = props;\n\n const {\n FieldErrorView,\n FieldErrorCaptureContext,\n fieldProps,\n fieldPropsContext,\n } = useFieldComponent(props);\n\n const rootClassName = clsx(fieldProps.className, className);\n\n
|
|
1
|
+
{"version":3,"file":"DatePicker.mjs","sources":["../../../../../../../src/components/DatePicker/DatePicker.tsx"],"sourcesContent":["import { type PropsWithChildren } from \"react\";\nimport clsx from \"clsx\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport * as Aria from \"react-aria-components\";\nimport { DateInput } from \"./components/DateInput\";\nimport { Popover } from \"@/components/Popover/Popover\";\nimport { useOverlayController } from \"@/lib/controller\";\nimport {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport { Calendar } from \"@/components/Calendar\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\nimport styles from \"./DatePicker.module.scss\";\n\nexport interface DatePickerProps<T extends Aria.DateValue = Aria.DateValue>\n extends\n PropsWithChildren<Omit<Aria.DatePickerProps<T>, \"children\" | \"ref\">>,\n FlowComponentProps<HTMLSpanElement> {}\n\n/** @flr-generate all */\nexport const DatePicker = flowComponent(\"DatePicker\", (props) => {\n const { children, className, onChange, ref, ...rest } = props;\n\n const popoverController = useOverlayController(\"Popover\");\n const {\n FieldErrorView,\n FieldErrorCaptureContext,\n fieldProps,\n fieldPropsContext,\n } = useFieldComponent(props);\n\n const rootClassName = clsx(fieldProps.className, className);\n\n return (\n <Aria.DatePicker\n {...rest}\n {...fieldProps}\n className={rootClassName}\n onOpenChange={(v) => popoverController.setOpen(v)}\n isOpen={popoverController.isOpen}\n onChange={(value) => {\n if (onChange) {\n onChange(value);\n }\n popoverController.close();\n }}\n >\n <FieldErrorCaptureContext>\n <DateInput isDisabled={props.isDisabled} ref={ref} />\n <PropsContextProvider props={fieldPropsContext}>\n {children}\n </PropsContextProvider>\n <Popover\n placement=\"bottom end\"\n isDialogContent\n controller={popoverController}\n >\n <Calendar className={styles.calendar} />\n </Popover>\n </FieldErrorCaptureContext>\n <FieldErrorView />\n </Aria.DatePicker>\n );\n});\n\nexport default DatePicker;\n"],"names":[],"mappings":";;;;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V,eAAA,EAAe,IAAA;AAAA,cACf,UAAA,EAAY,iBAAA;AAAA,cAEZ,QAAA,kBAAA,GAAA,CAAC,QAAA,EAAA,EAAS,SAAA,EAAW,MAAA,CAAO,QAAA,EAAU;AAAA;AAAA;AACxC,SAAA,EACF,CAAA;AAAA,4BACC,cAAA,EAAA,EAAe;AAAA;AAAA;AAAA,GAClB;AAEJ,CAAC;;;;"}
|
|
@@ -22,10 +22,19 @@ import 'dot-prop';
|
|
|
22
22
|
import { useOverlayController } from '../../lib/controller/overlay/useOverlayController.mjs';
|
|
23
23
|
import { flowComponent } from '../../lib/componentFactory/flowComponent.mjs';
|
|
24
24
|
import { useFieldComponent } from '../../lib/hooks/useFieldComponent.mjs';
|
|
25
|
+
import { useControlledHostValueProps } from '../../lib/remote/useControlledHostValueProps.mjs';
|
|
25
26
|
import styles from './DateRangePicker.module.scss.mjs';
|
|
26
27
|
|
|
27
28
|
const DateRangePicker = flowComponent("DateRangePicker", (props) => {
|
|
28
|
-
const {
|
|
29
|
+
const {
|
|
30
|
+
children,
|
|
31
|
+
className,
|
|
32
|
+
onChange,
|
|
33
|
+
ref,
|
|
34
|
+
withDatePickerPresets = false,
|
|
35
|
+
...rest
|
|
36
|
+
} = useControlledHostValueProps(props);
|
|
37
|
+
const popoverController = useOverlayController("Popover");
|
|
29
38
|
const {
|
|
30
39
|
FieldErrorView,
|
|
31
40
|
FieldErrorCaptureContext,
|
|
@@ -33,7 +42,12 @@ const DateRangePicker = flowComponent("DateRangePicker", (props) => {
|
|
|
33
42
|
fieldPropsContext
|
|
34
43
|
} = useFieldComponent(props);
|
|
35
44
|
const rootClassName = clsx(fieldProps.className, className);
|
|
36
|
-
const
|
|
45
|
+
const onDatePickerChange = (value) => {
|
|
46
|
+
if (onChange) {
|
|
47
|
+
onChange(value);
|
|
48
|
+
}
|
|
49
|
+
popoverController.close();
|
|
50
|
+
};
|
|
37
51
|
return /* @__PURE__ */ jsxs(
|
|
38
52
|
Aria.DateRangePicker,
|
|
39
53
|
{
|
|
@@ -41,12 +55,7 @@ const DateRangePicker = flowComponent("DateRangePicker", (props) => {
|
|
|
41
55
|
className: rootClassName,
|
|
42
56
|
onOpenChange: (v) => popoverController.setOpen(v),
|
|
43
57
|
isOpen: popoverController.isOpen,
|
|
44
|
-
onChange:
|
|
45
|
-
if (onChange) {
|
|
46
|
-
onChange(value);
|
|
47
|
-
}
|
|
48
|
-
popoverController.close();
|
|
49
|
-
},
|
|
58
|
+
onChange: onDatePickerChange,
|
|
50
59
|
children: [
|
|
51
60
|
/* @__PURE__ */ jsxs(FieldErrorCaptureContext, { children: [
|
|
52
61
|
/* @__PURE__ */ jsx(DateRangeInput, { isDisabled: props.isDisabled, ref }),
|
|
@@ -57,7 +66,13 @@ const DateRangePicker = flowComponent("DateRangePicker", (props) => {
|
|
|
57
66
|
placement: "bottom end",
|
|
58
67
|
isDialogContent: true,
|
|
59
68
|
controller: popoverController,
|
|
60
|
-
children: /* @__PURE__ */ jsx(
|
|
69
|
+
children: /* @__PURE__ */ jsx(
|
|
70
|
+
RangeCalendar,
|
|
71
|
+
{
|
|
72
|
+
withDatePickerPresets,
|
|
73
|
+
className: styles.calendar
|
|
74
|
+
}
|
|
75
|
+
)
|
|
61
76
|
}
|
|
62
77
|
)
|
|
63
78
|
] }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateRangePicker.mjs","sources":["../../../../../../../src/components/DateRangePicker/DateRangePicker.tsx"],"sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport clsx from \"clsx\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport * as Aria from \"react-aria-components\";\nimport { Popover } from \"@/components/Popover\";\nimport { RangeCalendar } from \"@/components/Calendar\";\nimport { DateRangeInput } from \"./components/DateRangeInput\";\nimport { useOverlayController } from \"@/lib/controller\";\nimport {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\nimport styles from \"./DateRangePicker.module.scss\";\n\nexport interface DateRangePickerProps<T extends Aria.DateValue = Aria.DateValue>\n extends\n PropsWithChildren<Omit<Aria.DateRangePickerProps<T>, \"children\" | \"ref\">>,\n FlowComponentProps<HTMLSpanElement> {}\n\n/** @flr-generate all */\nexport const DateRangePicker = flowComponent(\"DateRangePicker\", (props) => {\n const {
|
|
1
|
+
{"version":3,"file":"DateRangePicker.mjs","sources":["../../../../../../../src/components/DateRangePicker/DateRangePicker.tsx"],"sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport clsx from \"clsx\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport * as Aria from \"react-aria-components\";\nimport { Popover } from \"@/components/Popover\";\nimport { type DateRangePresets, RangeCalendar } from \"@/components/Calendar\";\nimport { DateRangeInput } from \"./components/DateRangeInput\";\nimport { useOverlayController } from \"@/lib/controller\";\nimport {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\nimport { useControlledHostValueProps } from \"@/lib/remote/useControlledHostValueProps\";\nimport type { RangeValue } from \"react-aria\";\nimport type { DateValue } from \"@internationalized/date\";\nimport styles from \"./DateRangePicker.module.scss\";\n\nexport interface DateRangePickerProps<T extends Aria.DateValue = Aria.DateValue>\n extends\n PropsWithChildren<Omit<Aria.DateRangePickerProps<T>, \"children\" | \"ref\">>,\n FlowComponentProps<HTMLSpanElement> {\n withDatePickerPresets?: boolean | DateRangePresets;\n}\n\n/** @flr-generate all */\nexport const DateRangePicker = flowComponent(\"DateRangePicker\", (props) => {\n const {\n children,\n className,\n onChange,\n ref,\n withDatePickerPresets = false,\n ...rest\n } = useControlledHostValueProps(props);\n\n const popoverController = useOverlayController(\"Popover\");\n const {\n FieldErrorView,\n FieldErrorCaptureContext,\n fieldProps,\n fieldPropsContext,\n } = useFieldComponent(props);\n\n const rootClassName = clsx(fieldProps.className, className);\n\n const onDatePickerChange = (value: RangeValue<DateValue> | null) => {\n if (onChange) {\n onChange(value);\n }\n popoverController.close();\n };\n\n return (\n <Aria.DateRangePicker\n {...rest}\n className={rootClassName}\n onOpenChange={(v) => popoverController.setOpen(v)}\n isOpen={popoverController.isOpen}\n onChange={onDatePickerChange}\n >\n <FieldErrorCaptureContext>\n <DateRangeInput isDisabled={props.isDisabled} ref={ref} />\n <PropsContextProvider props={fieldPropsContext}>\n {children}\n </PropsContextProvider>\n <Popover\n placement=\"bottom end\"\n isDialogContent\n controller={popoverController}\n >\n <RangeCalendar\n withDatePickerPresets={withDatePickerPresets}\n className={styles.calendar}\n />\n </Popover>\n </FieldErrorCaptureContext>\n <FieldErrorView />\n </Aria.DateRangePicker>\n );\n});\n\nexport default DateRangePicker;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0BO,MAAM,eAAA,GAAkB,aAAA,CAAc,iBAAA,EAAmB,CAAC,KAAA,KAAU;AACzE,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAA;AAAA,IACA,GAAA;AAAA,IACA,qBAAA,GAAwB,KAAA;AAAA,IACxB,GAAG;AAAA,GACL,GAAI,4BAA4B,KAAK,CAAA;AAErC,EAAA,MAAM,iBAAA,GAAoB,qBAAqB,SAAS,CAAA;AACxD,EAAA,MAAM;AAAA,IACJ,cAAA;AAAA,IACA,wBAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACF,GAAI,kBAAkB,KAAK,CAAA;AAE3B,EAAA,MAAM,aAAA,GAAgB,IAAA,CAAK,UAAA,CAAW,SAAA,EAAW,SAAS,CAAA;AAE1D,EAAA,MAAM,kBAAA,GAAqB,CAAC,KAAA,KAAwC;AAClE,IAAA,IAAI,QAAA,EAAU;AACZ,MAAA,QAAA,CAAS,KAAK,CAAA;AAAA,IAChB;AACA,IAAA,iBAAA,CAAkB,KAAA,EAAM;AAAA,EAC1B,CAAA;AAEA,EAAA,uBACE,IAAA;AAAA,IAAC,IAAA,CAAK,eAAA;AAAA,IAAL;AAAA,MACE,GAAG,IAAA;AAAA,MACJ,SAAA,EAAW,aAAA;AAAA,MACX,YAAA,EAAc,CAAC,CAAA,KAAM,iBAAA,CAAkB,QAAQ,CAAC,CAAA;AAAA,MAChD,QAAQ,iBAAA,CAAkB,MAAA;AAAA,MAC1B,QAAA,EAAU,kBAAA;AAAA,MAEV,QAAA,EAAA;AAAA,wBAAA,IAAA,CAAC,wBAAA,EAAA,EACC,QAAA,EAAA;AAAA,0BAAA,GAAA,CAAC,cAAA,EAAA,EAAe,UAAA,EAAY,KAAA,CAAM,UAAA,EAAY,GAAA,EAAU,CAAA;AAAA,0BACxD,GAAA,CAAC,oBAAA,EAAA,EAAqB,KAAA,EAAO,iBAAA,EAC1B,QAAA,EACH,CAAA;AAAA,0BACA,GAAA;AAAA,YAAC,OAAA;AAAA,YAAA;AAAA,cACC,SAAA,EAAU,YAAA;AAAA,cACV,eAAA,EAAe,IAAA;AAAA,cACf,UAAA,EAAY,iBAAA;AAAA,cAEZ,QAAA,kBAAA,GAAA;AAAA,gBAAC,aAAA;AAAA,gBAAA;AAAA,kBACC,qBAAA;AAAA,kBACA,WAAW,MAAA,CAAO;AAAA;AAAA;AACpB;AAAA;AACF,SAAA,EACF,CAAA;AAAA,4BACC,cAAA,EAAA,EAAe;AAAA;AAAA;AAAA,GAClB;AAEJ,CAAC;;;;"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/* */
|
|
3
3
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import
|
|
5
|
+
import styles from './Label.module.scss.mjs';
|
|
6
6
|
import * as Aria from 'react-aria-components';
|
|
7
7
|
import clsx from 'clsx';
|
|
8
8
|
import '../../lib/propsContext/propsContext.mjs';
|
|
@@ -23,8 +23,8 @@ const Label = flowComponent("Label", (props) => {
|
|
|
23
23
|
...rest
|
|
24
24
|
} = props;
|
|
25
25
|
const stringFormatter = useLocalizedStringFormatter(locales, "Label");
|
|
26
|
-
const rootClassName = unstyled ? className : clsx(
|
|
27
|
-
const optionalMarker = /* @__PURE__ */ jsx("span", { className:
|
|
26
|
+
const rootClassName = unstyled ? className : clsx(styles.label, isDisabled && styles.disabled, className);
|
|
27
|
+
const optionalMarker = /* @__PURE__ */ jsx("span", { className: styles.optional, children: stringFormatter.format("optional") });
|
|
28
28
|
const propsContext = {
|
|
29
29
|
ContextualHelpTrigger: {
|
|
30
30
|
tunnelId: "contextualHelp",
|
|
@@ -54,7 +54,7 @@ const Label = flowComponent("Label", (props) => {
|
|
|
54
54
|
} }),
|
|
55
55
|
/* @__PURE__ */ jsx(TunnelExit, { id: "right", children: (children2) => {
|
|
56
56
|
if (React.Children.count(children2) >= 1) {
|
|
57
|
-
return /* @__PURE__ */ jsx("div", { className:
|
|
57
|
+
return /* @__PURE__ */ jsx("div", { className: styles.right, children: children2 });
|
|
58
58
|
}
|
|
59
59
|
return void 0;
|
|
60
60
|
} })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Label.mjs","sources":["../../../../../../../src/components/Label/Label.tsx"],"sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport React from \"react\";\nimport styles from \"./Label.module.scss\";\nimport * as Aria from \"react-aria-components\";\nimport clsx from \"clsx\";\nimport { type PropsContext, PropsContextProvider } from \"@/lib/propsContext\";\nimport { useLocalizedStringFormatter } from \"@/components/TranslationProvider/useLocalizedStringFormatter\";\nimport locales from \"./locales/*.locale.json\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { TunnelExit, TunnelProvider } from \"@mittwald/react-tunnel\";\n\nexport interface LabelProps\n extends\n PropsWithChildren<Omit<Aria.LabelProps, \"children\">>,\n FlowComponentProps<HTMLLabelElement> {\n /** Whether the label should show an \"optional\" indicator. */\n optional?: boolean;\n /** Whether the label should be displayed as disabled. */\n isDisabled?: boolean;\n /* @internal */\n unstyled?: boolean;\n}\n\n/** @flr-generate all */\nexport const Label = flowComponent(\"Label\", (props) => {\n const {\n children,\n className,\n optional,\n isDisabled,\n ref,\n unstyled = false,\n ...rest\n } = props;\n\n const stringFormatter = useLocalizedStringFormatter(locales, \"Label\");\n\n const rootClassName = unstyled\n ? className\n : clsx(styles.label, isDisabled && styles.disabled, className);\n\n const optionalMarker = (\n <span className={styles.optional}>\n {stringFormatter.format(\"optional\")}\n </span>\n );\n\n const propsContext: PropsContext = {\n ContextualHelpTrigger: {\n tunnelId: \"contextualHelp\",\n Button: {\n tunnelId: null,\n },\n },\n Button: {\n tunnelId: \"right\",\n size: \"s\",\n },\n Action: {\n tunnelId: \"right\",\n Button: {\n tunnelId: null,\n },\n },\n };\n\n return (\n <PropsContextProvider props={propsContext}>\n <TunnelProvider>\n <Aria.Label {...rest} className={rootClassName} ref={ref}>\n {children}\n {optional && optionalMarker}\n <TunnelExit id=\"contextualHelp\">\n {(children) => {\n if (React.Children.count(children) >= 1) {\n return children;\n }\n\n return undefined;\n }}\n </TunnelExit>\n <TunnelExit id=\"right\">\n {(children) => {\n if (React.Children.count(children) >= 1) {\n return <div className={styles.right}>{children}</div>;\n }\n\n return undefined;\n }}\n </TunnelExit>\n </Aria.Label>\n </TunnelProvider>\n </PropsContextProvider>\n );\n});\n\nexport default Label;\n"],"names":["
|
|
1
|
+
{"version":3,"file":"Label.mjs","sources":["../../../../../../../src/components/Label/Label.tsx"],"sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport React from \"react\";\nimport styles from \"./Label.module.scss\";\nimport * as Aria from \"react-aria-components\";\nimport clsx from \"clsx\";\nimport { type PropsContext, PropsContextProvider } from \"@/lib/propsContext\";\nimport { useLocalizedStringFormatter } from \"@/components/TranslationProvider/useLocalizedStringFormatter\";\nimport locales from \"./locales/*.locale.json\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { TunnelExit, TunnelProvider } from \"@mittwald/react-tunnel\";\n\nexport interface LabelProps\n extends\n PropsWithChildren<Omit<Aria.LabelProps, \"children\">>,\n FlowComponentProps<HTMLLabelElement> {\n /** Whether the label should show an \"optional\" indicator. */\n optional?: boolean;\n /** Whether the label should be displayed as disabled. */\n isDisabled?: boolean;\n /* @internal */\n unstyled?: boolean;\n}\n\n/** @flr-generate all */\nexport const Label = flowComponent(\"Label\", (props) => {\n const {\n children,\n className,\n optional,\n isDisabled,\n ref,\n unstyled = false,\n ...rest\n } = props;\n\n const stringFormatter = useLocalizedStringFormatter(locales, \"Label\");\n\n const rootClassName = unstyled\n ? className\n : clsx(styles.label, isDisabled && styles.disabled, className);\n\n const optionalMarker = (\n <span className={styles.optional}>\n {stringFormatter.format(\"optional\")}\n </span>\n );\n\n const propsContext: PropsContext = {\n ContextualHelpTrigger: {\n tunnelId: \"contextualHelp\",\n Button: {\n tunnelId: null,\n },\n },\n Button: {\n tunnelId: \"right\",\n size: \"s\",\n },\n Action: {\n tunnelId: \"right\",\n Button: {\n tunnelId: null,\n },\n },\n };\n\n return (\n <PropsContextProvider props={propsContext}>\n <TunnelProvider>\n <Aria.Label {...rest} className={rootClassName} ref={ref}>\n {children}\n {optional && optionalMarker}\n <TunnelExit id=\"contextualHelp\">\n {(children) => {\n if (React.Children.count(children) >= 1) {\n return children;\n }\n\n return undefined;\n }}\n </TunnelExit>\n <TunnelExit id=\"right\">\n {(children) => {\n if (React.Children.count(children) >= 1) {\n return <div className={styles.right}>{children}</div>;\n }\n\n return undefined;\n }}\n </TunnelExit>\n </Aria.Label>\n </TunnelProvider>\n </PropsContextProvider>\n );\n});\n\nexport default Label;\n"],"names":["children"],"mappings":";;;;;;;;;;;;AAyBO,MAAM,KAAA,GAAQ,aAAA,CAAc,OAAA,EAAS,CAAC,KAAA,KAAU;AACrD,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAA;AAAA,IACA,UAAA;AAAA,IACA,G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AA,MACT;AAEA,MAAA,OAAO,MAAA;AAAA,IACT,CAAA,EACF,CAAA;AAAA,oBACA,GAAA,CAAC,UAAA,EAAA,EAAW,EAAA,EAAG,OAAA,EACZ,WAACA,SAAAA,KAAa;AACb,MAAA,IAAI,KAAA,CAAM,QAAA,CAAS,KAAA,CAAMA,SAAQ,KAAK,CAAA,EAAG;AACvC,QAAA,2BAAQ,KAAA,EAAA,EAAI,SAAA,EAAW,MAAA,CAAO,KAAA,EAAQ,UAAAA,SAAAA,EAAS,CAAA;AAAA,MACjD;AAEA,MAAA,OAAO,MAAA;AAAA,IACT,CAAA,EACF;AAAA,GAAA,EACF,GACF,CAAA,EACF,CAAA;AAEJ,CAAC;;;;"}
|
|
@@ -4,12 +4,12 @@ const label = "flow--label";
|
|
|
4
4
|
const disabled = "flow--label--disabled";
|
|
5
5
|
const optional = "flow--label--optional";
|
|
6
6
|
const right = "flow--label--right";
|
|
7
|
-
const
|
|
7
|
+
const styles = {
|
|
8
8
|
label: label,
|
|
9
9
|
disabled: disabled,
|
|
10
10
|
optional: optional,
|
|
11
11
|
right: right
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
export {
|
|
14
|
+
export { styles as default, disabled, label, optional, right };
|
|
15
15
|
//# sourceMappingURL=Label.module.scss.mjs.map
|