@swan-io/lake 3.0.0 → 3.1.0
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/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DateFormat, DatePickerDate
|
|
1
|
+
import { DateFormat, DatePickerDate } from "@swan-io/shared-business/src/components/DatePicker";
|
|
2
2
|
import { ValidatorResult } from "react-ux-form";
|
|
3
3
|
import { Simplify } from "type-fest";
|
|
4
4
|
type Item<T> = {
|
|
@@ -22,8 +22,6 @@ export type FilterRadioDef<T> = {
|
|
|
22
22
|
export type FilterDateDef<Values = unknown> = {
|
|
23
23
|
type: "date";
|
|
24
24
|
label: string;
|
|
25
|
-
monthNames: MonthNames;
|
|
26
|
-
dayNames: WeekDayNames;
|
|
27
25
|
cancelText: string;
|
|
28
26
|
submitText: string;
|
|
29
27
|
noValueText: string;
|
|
@@ -154,11 +154,11 @@ function FilterCheckbox({ label, items, width, checkAllLabel, value, onValueChan
|
|
|
154
154
|
return (_jsxs(Pressable, { role: "radio", "aria-checked": isSelected, style: ({ hovered }) => [styles.radio, hovered && styles.itemHovered], onPress: onPress, children: [_jsx(LakeCheckbox, { value: isSelected }), _jsx(Space, { width: 12 }), _jsx(Text, { style: styles.itemLabel, children: item.label })] }));
|
|
155
155
|
} }), _jsx(Space, { height: 8 }), _jsx(View, { style: styles.buttonContainer, children: _jsx(LakeButton, { color: "current", onPress: save, children: applyButtonLabel }) }), _jsx(Space, { height: 24 })] }) })] }));
|
|
156
156
|
}
|
|
157
|
-
function FilterDate({ label,
|
|
157
|
+
function FilterDate({ label, initialValue, noValueText, cancelText, submitText, dateFormat, isSelectable, validate, onSave, onPressRemove, autoOpen = false, }) {
|
|
158
158
|
const inputRef = useRef(null);
|
|
159
159
|
const [visible, { close, toggle }] = useDisclosure(autoOpen);
|
|
160
160
|
const value = useMemo(() => (isNotNullish(initialValue) ? dayjs(initialValue).format(dateFormat) : ""), [initialValue, dateFormat]);
|
|
161
|
-
return (_jsxs(View, { style: styles.container, children: [_jsx(FilterTag, { label: label, onPress: toggle, ref: inputRef, onPressRemove: onPressRemove, isActive: visible, value: isNotNullish(initialValue) ? dayjs(initialValue).format(dateFormat) : noValueText }), _jsx(DatePickerModal, { visible: visible,
|
|
161
|
+
return (_jsxs(View, { style: styles.container, children: [_jsx(FilterTag, { label: label, onPress: toggle, ref: inputRef, onPressRemove: onPressRemove, isActive: visible, value: isNotNullish(initialValue) ? dayjs(initialValue).format(dateFormat) : noValueText }), _jsx(DatePickerModal, { visible: visible, format: dateFormat, firstWeekDay: "monday", label: label, cancelLabel: cancelText, confirmLabel: submitText, value: value, isSelectable: isSelectable, validate: validate, onChange: value => {
|
|
162
162
|
const formattedValue = dayjs(value, dateFormat, true).toJSON();
|
|
163
163
|
onSave(formattedValue);
|
|
164
164
|
}, onDissmiss: close })] }));
|
|
@@ -211,7 +211,7 @@ export const FiltersStack = ({ filters, openedFilters, definition, onChangeOpene
|
|
|
211
211
|
onChangeFilters({ ...filters, [filterName]: undefined });
|
|
212
212
|
onChangeOpened(openedFilters.filter(f => f !== filterName));
|
|
213
213
|
} })))
|
|
214
|
-
.with({ type: "date" }, ({ type, label,
|
|
214
|
+
.with({ type: "date" }, ({ type, label, noValueText, cancelText, submitText, dateFormat, isSelectable, validate, }) => (_jsx(FilterDate, { label: label, noValueText: noValueText, cancelText: cancelText, submitText: submitText, dateFormat: dateFormat, autoOpen: lastOpenedFilter === filterName, isSelectable: isSelectable ? date => isSelectable(date, filters) : undefined, validate: validate ? value => validate(value, filters) : undefined, initialValue: getFilterValue(type, filters, filterName), onSave: value => onChangeFilters({ ...filters, [filterName]: value }), onPressRemove: () => {
|
|
215
215
|
onChangeFilters({ ...filters, [filterName]: undefined });
|
|
216
216
|
onChangeOpened(openedFilters.filter(f => f !== filterName));
|
|
217
217
|
} })))
|