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.js CHANGED
@@ -9014,6 +9014,53 @@ function CustomRule(_ref8) {
9014
9014
  })
9015
9015
  });
9016
9016
  }
9017
+ function RemoveEndDate(_ref9) {
9018
+ let {
9019
+ title,
9020
+ onChange
9021
+ } = _ref9;
9022
+ const handleUnsetClick = React.useCallback(() => {
9023
+ onChange(sanity.unset(["endDate"]));
9024
+ }, [onChange]);
9025
+ return /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
9026
+ padding: 4,
9027
+ radius: 2,
9028
+ tone: "caution",
9029
+ "data-ui": "Alert",
9030
+ children: /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
9031
+ children: [/* @__PURE__ */jsxRuntime.jsx(ui.Box, {
9032
+ children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
9033
+ size: 1,
9034
+ children: /* @__PURE__ */jsxRuntime.jsx(icons.WarningOutlineIcon, {})
9035
+ })
9036
+ }), /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
9037
+ space: 3,
9038
+ flex: 1,
9039
+ marginLeft: 3,
9040
+ children: [/* @__PURE__ */jsxRuntime.jsxs(ui.Text, {
9041
+ size: 1,
9042
+ weight: "semibold",
9043
+ children: ["The ", title ? lodash.upperFirst(title) : "current", " field has an end date"]
9044
+ }), /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
9045
+ children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
9046
+ as: "p",
9047
+ muted: true,
9048
+ size: 1,
9049
+ children: "This field has an end date value, but the end date is currently disabled for this field."
9050
+ })
9051
+ }), /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
9052
+ icon: icons.TrashIcon,
9053
+ tone: "critical",
9054
+ text: /* @__PURE__ */jsxRuntime.jsx(jsxRuntime.Fragment, {
9055
+ children: "Remove end date"
9056
+ }),
9057
+ onClick: handleUnsetClick,
9058
+ width: "100%"
9059
+ })]
9060
+ })]
9061
+ })
9062
+ });
9063
+ }
9017
9064
  function RecurringDates(props) {
9018
9065
  var _a, _b, _c;
9019
9066
  const {
@@ -9024,7 +9071,8 @@ function RecurringDates(props) {
9024
9071
  pluginConfig
9025
9072
  } = props;
9026
9073
  const {
9027
- options
9074
+ options,
9075
+ title
9028
9076
  } = schemaType;
9029
9077
  const {
9030
9078
  defaultRecurrences,
@@ -9074,12 +9122,16 @@ function RecurringDates(props) {
9074
9122
  ...dateTimeOptions
9075
9123
  };
9076
9124
  }
9125
+ const hasEndDate = currentValue && currentValue.endDate;
9077
9126
  return /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
9078
9127
  space: 3,
9079
9128
  children: [/* @__PURE__ */jsxRuntime.jsxs(ui.Grid, {
9080
9129
  columns: hideEndDate ? 1 : 2,
9081
9130
  gap: 3,
9082
- children: [/* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
9131
+ children: [hasEndDate && hideEndDate && /* @__PURE__ */jsxRuntime.jsx(RemoveEndDate, {
9132
+ title,
9133
+ onChange
9134
+ }), /* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
9083
9135
  align: "flex-end",
9084
9136
  gap: 2,
9085
9137
  children: /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
@@ -9144,7 +9196,6 @@ function RecurringDates(props) {
9144
9196
  }
9145
9197
  var recurringDateSchema = config => {
9146
9198
  const {
9147
- hideEndDate,
9148
9199
  dateTimeOptions
9149
9200
  } = config;
9150
9201
  return sanity.defineField({
@@ -9172,7 +9223,7 @@ var recurringDateSchema = config => {
9172
9223
  name: "rrule",
9173
9224
  type: "string",
9174
9225
  hidden: true
9175
- })].filter(field => !(field.name === "endDate" && hideEndDate)),
9226
+ })],
9176
9227
  components: {
9177
9228
  input: props => RecurringDates({
9178
9229
  ...props,