sanity-plugin-recurring-dates 1.0.3 → 1.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/LICENSE +1 -1
- package/README.md +18 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +319 -286
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +319 -286
- package/dist/index.js.map +1 -1
- package/package.json +16 -16
- package/src/components/RecurringDate.tsx +21 -2
- package/src/schema/recurringDates.tsx +3 -3
- package/src/types.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sanity-plugin-recurring-dates",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Add a custom input component to your Sanity Studio to manage recurring dates (e.g. for events)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -47,45 +47,45 @@
|
|
|
47
47
|
"prepare": "husky install"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@sanity/icons": "^2.4.1",
|
|
51
50
|
"@sanity/incompatible-plugin": "^1.0.4",
|
|
52
|
-
"@sanity/ui": "^1.7.4",
|
|
53
51
|
"lodash": "^4.17.21",
|
|
54
52
|
"rrule": "^2.7.2",
|
|
55
53
|
"sanity-plugin-utils": "^1.6.2"
|
|
56
54
|
},
|
|
57
55
|
"devDependencies": {
|
|
58
|
-
"@commitlint/cli": "^18.4.
|
|
59
|
-
"@commitlint/config-conventional": "^18.4.
|
|
60
|
-
"@sanity/pkg-utils": "^3.3.
|
|
56
|
+
"@commitlint/cli": "^18.4.4",
|
|
57
|
+
"@commitlint/config-conventional": "^18.4.4",
|
|
58
|
+
"@sanity/pkg-utils": "^3.3.7",
|
|
61
59
|
"@sanity/plugin-kit": "^3.1.10",
|
|
62
60
|
"@sanity/semantic-release-preset": "^4.1.6",
|
|
63
|
-
"@types/react": "^18.2.
|
|
64
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
65
|
-
"@typescript-eslint/parser": "^6.
|
|
66
|
-
"eslint": "^8.
|
|
61
|
+
"@types/react": "^18.2.47",
|
|
62
|
+
"@typescript-eslint/eslint-plugin": "^6.18.1",
|
|
63
|
+
"@typescript-eslint/parser": "^6.18.1",
|
|
64
|
+
"eslint": "^8.56.0",
|
|
67
65
|
"eslint-config-prettier": "^9.1.0",
|
|
68
66
|
"eslint-config-sanity": "^7.0.1",
|
|
69
|
-
"eslint-plugin-prettier": "^5.
|
|
67
|
+
"eslint-plugin-prettier": "^5.1.2",
|
|
70
68
|
"eslint-plugin-react": "^7.33.2",
|
|
71
69
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
72
70
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
73
71
|
"husky": "^8.0.3",
|
|
74
|
-
"lint-staged": "^
|
|
72
|
+
"lint-staged": "^15.2.0",
|
|
75
73
|
"npm-run-all": "^4.1.5",
|
|
76
74
|
"prettier": "^3.1.1",
|
|
77
|
-
"prettier-plugin-packagejson": "^2.4.
|
|
75
|
+
"prettier-plugin-packagejson": "^2.4.9",
|
|
78
76
|
"react": "^18.2.0",
|
|
79
77
|
"react-dom": "^18.2.0",
|
|
80
78
|
"react-is": "^18.2.0",
|
|
81
79
|
"rimraf": "^5.0.1",
|
|
82
|
-
"sanity": "^3.
|
|
83
|
-
"styled-components": "^6.1.
|
|
80
|
+
"sanity": "^3.23.4",
|
|
81
|
+
"styled-components": "^6.1.8",
|
|
84
82
|
"typescript": "^5.3.3"
|
|
85
83
|
},
|
|
86
84
|
"peerDependencies": {
|
|
87
85
|
"react": "^18",
|
|
88
|
-
"sanity": "^3"
|
|
86
|
+
"sanity": "^3",
|
|
87
|
+
"@sanity/ui": "^1 || ^2.0.0-beta",
|
|
88
|
+
"@sanity/icons": "^2"
|
|
89
89
|
},
|
|
90
90
|
"engines": {
|
|
91
91
|
"node": ">=14"
|
|
@@ -21,7 +21,7 @@ type RecurringDateObjectSchemaType = Omit<ObjectSchemaType, 'options'> & {
|
|
|
21
21
|
export function RecurringDates(props: RecurringDatesProps) {
|
|
22
22
|
const {onChange, members, value: currentValue, schemaType, pluginConfig} = props
|
|
23
23
|
const {options, title}: RecurringDateObjectSchemaType = schemaType
|
|
24
|
-
const {defaultRecurrences, hideEndDate, hideCustom, dateTimeOptions} = {
|
|
24
|
+
const {defaultRecurrences, hideEndDate, hideCustom, dateTimeOptions, dateOnly} = {
|
|
25
25
|
...pluginConfig,
|
|
26
26
|
...options,
|
|
27
27
|
}
|
|
@@ -85,6 +85,25 @@ export function RecurringDates(props: RecurringDatesProps) {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
if (dateOnly === true) {
|
|
89
|
+
if (startDateMember?.kind == 'field') {
|
|
90
|
+
startDateMember.field.schemaType.name = 'date'
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (endDateMember?.kind == 'field') {
|
|
94
|
+
endDateMember.field.schemaType.name = 'date'
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
// we need to explicitly set the schemaType to datetime
|
|
98
|
+
if (startDateMember?.kind == 'field') {
|
|
99
|
+
startDateMember.field.schemaType.name = 'datetime'
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (endDateMember?.kind == 'field') {
|
|
103
|
+
endDateMember.field.schemaType.name = 'datetime'
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
88
107
|
// Do we have an end date set for this field?
|
|
89
108
|
const hasEndDate = currentValue && currentValue.endDate
|
|
90
109
|
|
|
@@ -114,7 +133,7 @@ export function RecurringDates(props: RecurringDatesProps) {
|
|
|
114
133
|
</Feedback>
|
|
115
134
|
) : (
|
|
116
135
|
<Select onChange={handleChange} value={currentValue?.rrule}>
|
|
117
|
-
<option value="">Doesn
|
|
136
|
+
<option value="">Doesn't repeat</option>
|
|
118
137
|
{availableRecurrences.map((recurrence) => {
|
|
119
138
|
if (!recurrence) {
|
|
120
139
|
return null
|
|
@@ -4,7 +4,7 @@ import {RecurringDates} from '../components/RecurringDate'
|
|
|
4
4
|
import {PluginConfig, WithRequiredProperty} from '../types'
|
|
5
5
|
|
|
6
6
|
export default (config: WithRequiredProperty<PluginConfig, 'defaultRecurrences'>) => {
|
|
7
|
-
const {dateTimeOptions} = config
|
|
7
|
+
const {dateTimeOptions, dateOnly} = config
|
|
8
8
|
|
|
9
9
|
return defineField({
|
|
10
10
|
name: 'recurringDates',
|
|
@@ -14,14 +14,14 @@ export default (config: WithRequiredProperty<PluginConfig, 'defaultRecurrences'>
|
|
|
14
14
|
defineField({
|
|
15
15
|
title: 'Start Date',
|
|
16
16
|
name: 'startDate',
|
|
17
|
-
type: 'datetime',
|
|
17
|
+
type: dateOnly ? 'date' : 'datetime',
|
|
18
18
|
options: dateTimeOptions,
|
|
19
19
|
validation: (Rule) => Rule.required(),
|
|
20
20
|
}),
|
|
21
21
|
defineField({
|
|
22
22
|
title: 'End Date',
|
|
23
23
|
name: 'endDate',
|
|
24
|
-
type: 'datetime',
|
|
24
|
+
type: dateOnly ? 'date' : 'datetime',
|
|
25
25
|
options: dateTimeOptions,
|
|
26
26
|
validation: (Rule) => Rule.min(Rule.valueOfField('startDate')),
|
|
27
27
|
}),
|