sanity-plugin-recurring-dates 1.0.0 → 1.0.1
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.esm.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { set, ObjectInputMember, defineField, definePlugin } from 'sanity';
|
|
2
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
1
|
+
import { set, unset, ObjectInputMember, defineField, definePlugin } from 'sanity';
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { Card, Text, Box, Grid, TextInput, useForwardedRef, Flex, Select, Button, useClickOutside, LayerProvider, Popover, Stack, Dialog, Radio } from '@sanity/ui';
|
|
4
4
|
import { range, upperFirst } from 'lodash';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import React__default, { useState, useEffect, PureComponent, useCallback, forwardRef, useRef, useMemo } from 'react';
|
|
7
7
|
import { rrulestr, Weekday, RRule } from 'rrule';
|
|
8
8
|
import { Feedback } from 'sanity-plugin-utils';
|
|
9
|
-
import { ChevronLeftIcon, ChevronRightIcon, CalendarIcon } from '@sanity/icons';
|
|
9
|
+
import { ChevronLeftIcon, ChevronRightIcon, CalendarIcon, WarningOutlineIcon, TrashIcon } from '@sanity/icons';
|
|
10
10
|
const DEFAULT_RECURRENCES = ["RRULE:FREQ=DAILY;INTERVAL=1", "RRULE:FREQ=WEEKLY;INTERVAL=1", "RRULE:FREQ=MONTHLY;INTERVAL=1", "RRULE:FREQ=YEARLY;INTERVAL=1"];
|
|
11
11
|
const DEFAULT_CONFIG = {
|
|
12
12
|
defaultRecurrences: DEFAULT_RECURRENCES
|
|
@@ -8990,6 +8990,53 @@ function CustomRule(_ref8) {
|
|
|
8990
8990
|
})
|
|
8991
8991
|
});
|
|
8992
8992
|
}
|
|
8993
|
+
function RemoveEndDate(_ref9) {
|
|
8994
|
+
let {
|
|
8995
|
+
title,
|
|
8996
|
+
onChange
|
|
8997
|
+
} = _ref9;
|
|
8998
|
+
const handleUnsetClick = useCallback(() => {
|
|
8999
|
+
onChange(unset(["endDate"]));
|
|
9000
|
+
}, [onChange]);
|
|
9001
|
+
return /* @__PURE__ */jsx(Card, {
|
|
9002
|
+
padding: 4,
|
|
9003
|
+
radius: 2,
|
|
9004
|
+
tone: "caution",
|
|
9005
|
+
"data-ui": "Alert",
|
|
9006
|
+
children: /* @__PURE__ */jsxs(Flex, {
|
|
9007
|
+
children: [/* @__PURE__ */jsx(Box, {
|
|
9008
|
+
children: /* @__PURE__ */jsx(Text, {
|
|
9009
|
+
size: 1,
|
|
9010
|
+
children: /* @__PURE__ */jsx(WarningOutlineIcon, {})
|
|
9011
|
+
})
|
|
9012
|
+
}), /* @__PURE__ */jsxs(Stack, {
|
|
9013
|
+
space: 3,
|
|
9014
|
+
flex: 1,
|
|
9015
|
+
marginLeft: 3,
|
|
9016
|
+
children: [/* @__PURE__ */jsxs(Text, {
|
|
9017
|
+
size: 1,
|
|
9018
|
+
weight: "semibold",
|
|
9019
|
+
children: ["The ", title ? upperFirst(title) : "current", " field has an end date"]
|
|
9020
|
+
}), /* @__PURE__ */jsx(Box, {
|
|
9021
|
+
children: /* @__PURE__ */jsx(Text, {
|
|
9022
|
+
as: "p",
|
|
9023
|
+
muted: true,
|
|
9024
|
+
size: 1,
|
|
9025
|
+
children: "This field has an end date value, but the end date is currently disabled for this field."
|
|
9026
|
+
})
|
|
9027
|
+
}), /* @__PURE__ */jsx(Button, {
|
|
9028
|
+
icon: TrashIcon,
|
|
9029
|
+
tone: "critical",
|
|
9030
|
+
text: /* @__PURE__ */jsx(Fragment, {
|
|
9031
|
+
children: "Remove end date"
|
|
9032
|
+
}),
|
|
9033
|
+
onClick: handleUnsetClick,
|
|
9034
|
+
width: "100%"
|
|
9035
|
+
})]
|
|
9036
|
+
})]
|
|
9037
|
+
})
|
|
9038
|
+
});
|
|
9039
|
+
}
|
|
8993
9040
|
function RecurringDates(props) {
|
|
8994
9041
|
var _a, _b, _c;
|
|
8995
9042
|
const {
|
|
@@ -9000,7 +9047,8 @@ function RecurringDates(props) {
|
|
|
9000
9047
|
pluginConfig
|
|
9001
9048
|
} = props;
|
|
9002
9049
|
const {
|
|
9003
|
-
options
|
|
9050
|
+
options,
|
|
9051
|
+
title
|
|
9004
9052
|
} = schemaType;
|
|
9005
9053
|
const {
|
|
9006
9054
|
defaultRecurrences,
|
|
@@ -9050,12 +9098,16 @@ function RecurringDates(props) {
|
|
|
9050
9098
|
...dateTimeOptions
|
|
9051
9099
|
};
|
|
9052
9100
|
}
|
|
9101
|
+
const hasEndDate = currentValue && currentValue.endDate;
|
|
9053
9102
|
return /* @__PURE__ */jsxs(Stack, {
|
|
9054
9103
|
space: 3,
|
|
9055
9104
|
children: [/* @__PURE__ */jsxs(Grid, {
|
|
9056
9105
|
columns: hideEndDate ? 1 : 2,
|
|
9057
9106
|
gap: 3,
|
|
9058
|
-
children: [/* @__PURE__ */jsx(
|
|
9107
|
+
children: [hasEndDate && hideEndDate && /* @__PURE__ */jsx(RemoveEndDate, {
|
|
9108
|
+
title,
|
|
9109
|
+
onChange
|
|
9110
|
+
}), /* @__PURE__ */jsx(Flex, {
|
|
9059
9111
|
align: "flex-end",
|
|
9060
9112
|
gap: 2,
|
|
9061
9113
|
children: /* @__PURE__ */jsx(Box, {
|
|
@@ -9120,7 +9172,6 @@ function RecurringDates(props) {
|
|
|
9120
9172
|
}
|
|
9121
9173
|
var recurringDateSchema = config => {
|
|
9122
9174
|
const {
|
|
9123
|
-
hideEndDate,
|
|
9124
9175
|
dateTimeOptions
|
|
9125
9176
|
} = config;
|
|
9126
9177
|
return defineField({
|
|
@@ -9148,7 +9199,7 @@ var recurringDateSchema = config => {
|
|
|
9148
9199
|
name: "rrule",
|
|
9149
9200
|
type: "string",
|
|
9150
9201
|
hidden: true
|
|
9151
|
-
})]
|
|
9202
|
+
})],
|
|
9152
9203
|
components: {
|
|
9153
9204
|
input: props => RecurringDates({
|
|
9154
9205
|
...props,
|